Copy Master Boot Record (MBR) in UNIX / Linux

Master Boot Record

An MBR (master boot record) is the 512-byte boot sector that is the information stored in the first sector of any hard disk, floppy, USB drive which identifies where an os is located in the memory. Once identified, it is booted (loaded) into the computer’s main storage or random access memory.

Mater Boot Record, long the standard bootloader and partition in PC operating systems was introduced in 1983

  • When the computer is turned on, both the central processor and BIOS expect to find the code for booting in a specific address in the RAM.
  • That code must reside at a specific location on the first block storage device identified by BIOS, or the system will no boot.

MBR is always involved in the boot process of an MBR partition. The only time you can “escape” it is when using a non-BIOS (such as EFI or ARM) system and GPT.

MBR partitions have several limitations apart from those associated with BIOS and CHS addressing:

  • MBR devices report 512-byte sector sizes,even if the device uses 4k sectors, which can lead to degraded performance.
  • The partitions must always start on a track boundary and end on a cylinder boundary; this is true whether CHS or LBA addressing is used
  • If a drive has more than one partition, the bootable partition must be marked “active.”

MBR Size

446 + 64 + 2 = 512 bytes

Where,

446 bytes – Bootstrap.
64 bytes – Partition table.
2 bytes – Signature.

How to copy MBR with dd command

To copy master boot record in Linux dd command is used. This command (dd) works under all the Linux distros and other UNIX like operating systems.

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

This command will copy full 512 bytes (Master boot record) from sda to sdb drive. This will only work if both storage (partition) have identically sized partitions.

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

The above commands will preserve the partitioning schema.

Add Comment