Linux-Tip News

We are proud to present the Linux-Tip Portal in a new design and hope you will find it helpful, whether you are new to Linux or a seasoned user. We will attempt to provide you with effective tips and tricks, or at least to point you in the direction of the help you may need. We would like to offer a great big "Thanks!" for their excellent work to Jommla!  and  to RocketTheme . Please enjoy Linux news and workshops. Feel free to send your comments and suggestions.

 
Home arrow Blog arrow Trick: Backup and Restore MBR
Trick: Backup and Restore MBR Print E-mail
Friday, 27 June 2008

Backing up Master Boot Record (MBR)

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

 
< Prev   Next >

Virus Info Feed

Alexa Traffic Stats


Urlaub Spanien