My bootloader of choice is always grub, however some installations use lilo and the method I often use to remove lilo is to zero the MBR. Now I have read on LQ that if I use the following command the boot code will be zero'd but the partition table remains intact :
Code:
# dd if=/dev/zero of=/dev/sda bs=446 count=1
Code:
# dd if=/dev/zero of=/dev/sda bs=512 count=1
That second command erases the partition table and fdisk will report that the disk has no partitions.
When trying to install GRUB to re-write over LILO I was getting L99 99 99 99 99 errors on boot up. When I done a hexdump to view my MBR it showed that fragments of LILO were still installed. The way I eventually got grub to install properly was to zero 446 bytes and then re-install it. I was installing SLAX on a spare partiton and it uses LILO as the bootloader and gives you no alternative but to load it into the MBR of hda and not in any specified partition.
With all 512 bytes to 0, it must show the entire disk as unallocated space. Data aren't erased, so you could perhaps restore the deleted partitions using "testdisk".
But, if you put all the MBR to 0, then the disk label is deleted too.
On my system, I just made a label using "e2label". Using dd, I found this in the 3rd sector of the partition**---nowhere near the 1st sector / MBR.
**specifically, at an offset of OX478 from the start of the partition. This is in the 63-sector zone that precedes the start of the real partition data.
That’s because labeling a partition has nothing to do with the MBR. It is filesystem-specific (in this case ext2/3) and will undoubtedly affect whatever partition in which your filesystem resides.
As for masterclassic’s suggestion of using testdisk, you might instead backup and restore the partition table (and only the partition table).
"disk label" i) The id bytes that Windoze stuffs in there (and the rest of the world ignores), or ii) the "signature" bytes at the end (last 2 bytes) of the first sector. |
I think that most manufacturers now sale their disks with this signature already written. Obviously, if we install Linux or another system on an empty disk, it writes this signature in order to proceed to the disk partitioning and format.
Of course, I always prefer to backup the MBR before any partitioning work, rather than recovering Testdisk is a tool we can use if something goes wrong. It is contained in several live cds, as in Gparted livecd (from the terminal), and I think in the Ultimate Boot cd.fdisk -l
No comments:
Post a Comment