Many people often think that to have a clean hard drive just repartition the disk and recreate the filesystems. The reality is not so.
For MBR disk partition table, disk partitioning tools like fdisk, cfdisk, parted, and filesystem creation tools like mkfs.ext4 only manipulate the first sector of the disk (sector 0) and sectors beginning from the first partition. We use a USB memory stick to illustrate, the device name is /dev/sdb
This hard disk has one partition starting from sector 63. Thus 62 sectors from sector 1 to sector 62 are not affected by normal disk tools. Even the use of wipefs to wipe all signatures on the disk did not remove the information in these 62 sectors.
This space should have originally been empty. If it does not, we call the disk is not clean to install new operating system.
This happens even if you buy a brand new hard drive, which the manufacturer can code to track equipment or take care of customers. But the risk is that it may be the code of a bootkits root virus.
The solution is to create a file containing all 0 bytes and overwrite that area. The following program creates the file zerodisk.dat containing all bytes 0, which is the size of 62 sectors (1 sector has 512 bytes)
#include <stdlib.h> #include <stdio.h> #include <strings.h> int main() { FILE *f = fopen("zerodisk.dat", "w"); char data[512 * 62]; bzero(data, 512 * 62); fwrite(data, 512, 62, f); fclose(f); return 0; }
Now we use dd to overwrite the file content to the location on the disk, as the root
user:
dd if=zerodisk.dat of=/dev/sdb seek=1 conv=notrunc
You now have the necessary empty disk area, feel free to use disk tools and start installing the new operating system. After installing GRUB (bootloader), its image will be safely written to that empty area.
Contact: tuyen@omarine.org
Comments
buy dumpscc check 3 years, 8 months ago
Hɑve you ever thought aboսt ading a little ƅit more than just yyour aгticles?
Link | ReplyI mean, what you say is important and all.
Nevеrtheless tһink of if you ɑdded some great picturеs or videos to give your posts more, "pop"!Yoᥙrr contnt
іѕ excellent but with images and videօs, this site could certainly be one off the greateѕt in its field.
Superb blog!
Tuyen Pham Thanh 3 years, 8 months ago
Thanks for your comments. I will collect more illustrative media if possible.
Link | Replyholymolyslots 3 years, 7 months ago
Playing slots iss definitely ann thrilling game.
Link | Replysoundcloud.com 3 years, 1 month ago
you are in reality a excellent webmaster. The site loading pace is
Link | Replyamazing. It sort of feels that you are doing any distinctive trick.
Also, The contents are masterwork. you have done a wonderful activity in this
matter!
tech news dubai 3 years, 1 month ago
Good answers in return of this question with firm arguments
Link | Replyand describing everything concerning that.
Don Quinn 3 years, 8 months ago
How to install 6.2 on 4TB gpt drive?
Link | ReplyTuyen Pham Thanh 3 years, 8 months ago
Mount your target partition as the root partition manually, for example /dev/sda1:
Link | Replymount /dev/sda1 /mnt
After installation, create fstab:
echo /dev/sda1 / ext4 defaults 1 1 > /mnt/etc/fstab
before restarting.
New Comment