• RSS
  • subscribe
  • twitter

A simply way to backup your Master Boot Record(MBR)

tools

First things first; What is the Master Boot Record (MBR)?
The Master Boot Record(MBR) consists of the first 512byte (half a Kbyte) of the Hard Disk. Inside this fundamental part of the Hd are stored all the commands necessary for the PC to boot up the OS. Practically the firmware found in the ROM of the BIOS loads and runs all what it finds on the MBR and MBR on its part loads up the OS.
The MBR contains a partition table, that is used by the system to understand the structure of the HD and a boot loader(for Grub o Lilo) that loads the kernel of the OS.

To create a backup copy of the MBR, the simplest method is using the dd command. With this tool it is possible to save the contents of the first 512byte of a Hard Disk(MBR) in a file;

# dd if=/dev/hdX of=/media/disk/MBR.img bs=512 count=1
(where is X = device name e.g. /dev/hda)

In this case the whole MBR would be stored in the MBR.img file in your pendrive

To view the contents of this file, first move into the pendrive or folder(whatever) and do

# od -xa MBR.img

So if you want to restore your corrupted MBR, then you can do it with;

# dd if= media/disk/MBR.img of=/dev/hdX bs= 512 count=1