Copying the MBR…

A small tip. We want to copy the MBR from one disk to another disk with a different partition table.

Copying the MBR directly (only between identical disks!):

#dd if=/dev/sda of=/dev/sdb bs=512 count=1

This copies 512 bytes from disk sda to sdb, but it will work only with identical partition tables.

To copy between different disks:

Copy to a file:

# dd if=/dev/sda of=/tmp/mbrsda.bak bs=512 count=1

Restore to another disk:

# dd if=/tmp/mbrsda.bak of=/dev/sdb bs=446 count=1

This way we preserve the partitioning scheme.