Backup MBR in Linux

Master boot record (MBR) — code and data located in the first 512 bytes of the hard disk needed to boot the operating system.

From 512 bytes of MBR code contains:
446 bytes — Bootstrap
64 bytes — Partition table
2 bytes — Signature

Backup MBR:

dd if=/dev/sda of=/dir/sda.mbr bs=512 count=1

Options:
if – source
of – file or destination device
bs – the number of bytes to be read at a time
count – the number of times a record

Check whether the file was created:

file /dir/sda.mbr

To restore the MBR run the command:

dd if=/dir/sda.mbr of=/dev/sda bs=512 count=1

You can also use the sfdisk utility.

Creating a copy of the partition table:

sfdisk -d /dev/sda > /dir/sda.sfdisk

Restore partition table:

sfdisk /dev/sda < /dir/sda.sfdisk

Leave a comment

Leave a Reply