Backing up Master Boot Record



The MBR is a 512 byte segment on the very first sector of your hard drive composed of three parts: 1) the boot code which is 446 bytes long, 2) the partiton table which is 64 btyes long, and 3) the boot code signature which is 2 bytes long.
The core of the backup command is dd—which will be familiar to every system administrator, especially to those who intend to clone an entire hard disk. To see all the options type man dd. As we want to back up only the first 512 bytes we need to append some arguments to it. Here is the full command you need (and remember to run it as the root user, su (and sudo for Ubuntu users):

dd if=/dev/hda of=/home/richmondg/mbr_backup bs=512 count=1
Restoring the MBR
You can use a live CD to access your hard drive and read the backup off any removable media such as a USB stick. Here is the command:

dd if=/dev/sda/mbr_backup of=/dev/hda bs=512 count=1
Again, amend sda to read where you saved the MBR and run the command as root. If you wish to kill the MBR altogether, including the partition table, then you can overwrite it with a series of zeros:

dd if=/dev/zero of=/dev/hda bs=512 count=1
If you want to kill the MBR but leave the partition table intact then simply change 512 to 446.
Another way to repair the mbr of your HDD device is install LILO then type (replacing x with the letter of your HDDdevice) :

lilo -M /dev/sdx


Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

Popular Posts