How To Copy Master Boot Record (MBR) Between Hard Disks

By Angsuman Chakraborty, Gaea News Network
Tuesday, March 18, 2008

In Linux you can use the dd command to copy MBR from one hard disk to another. You can also use dd to backup your master boot record to a different (or same) media. One of the common use of MBR copying is to ensure transparent fail-over in RAID-1 hard-disk array, should one hard-disks fail. Read more for examples.

How to copy master boot record from hda to hdb
dd if=/dev/hda of=/dev/hdb bs=512 count=1

BTW: Today I used this command to create identical MBR on my RAID-1 array. So when I removed the first hard-disk from the RAID-1 array, the second hard-disk continued to function without any issue. It is as if nothing has happened at all. Only when you look at /proc/mdstat you can see that only one hard-disk of the array is available.

How to backup master boot record of hda
dd if=/dev/hda bs=512 count=1 > hda_backup

hda_backup now contains the backup of MBR of hda.

How to restore master boot record of hda from hda_backup backup file
dd if=hda_backup of=/dev/hda bs=512 count=1

Note: Replace hda and hdb with the respective identifier for your drives. Hard disks have identifiers like hda, hdb… or sda, sdb… etc. on Linux machines.

will not be displayed