Backing up the Master Boot Record (MBR) before changing partitions, installing another operating system, or experimenting with boot loaders preserves a known-good boot path. A small backup image created in advance can be restored quickly if the primary disk stops booting after modifications, avoiding longer recovery work.

On Linux systems that use BIOS-style partitioning, the MBR occupies the first 512 bytes of a disk and contains the initial boot loader code, the primary partition table, and a signature. The dd utility reads and writes raw blocks from devices such as /dev/sda and can copy this 512-byte region into a regular file without altering its structure, which is ideal for saving and restoring the MBR.

Running dd with elevated privileges against the wrong device or in the wrong direction can destroy data, so disk names must be checked carefully before proceeding. Keeping the backup on separate storage such as a USB drive or network share protects it from disk failures, and including the disk name and date in the file name helps track which backup belongs to which system.

Steps to back up Master Boot Record (MBR) in Linux:

  1. Open a terminal with access to sudo on the Linux system.
    $ whoami
    root
  2. List available disks to identify the device that holds the MBR to be backed up.
    $ lsblk
    NAME      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
    loop0       7:0    0   512M  0 loop /mnt/bench
    loop1       7:1    0    64M  0 loop 
    loop2       7:2    0    32M  0 loop 
    loop3       7:3    0    64M  0 loop 
    `-loop3p1 259:0    0    15M  0 part 
    nbd0       43:0    0     0B  0 disk 
    nbd1       43:32   0     0B  0 disk 
    nbd2       43:64   0     0B  0 disk 
    nbd3       43:96   0     0B  0 disk 
    nbd4       43:128  0     0B  0 disk 
    nbd5       43:160  0     0B  0 disk 
    nbd6       43:192  0     0B  0 disk 
    nbd7       43:224  0     0B  0 disk 
    vda       254:0    0   1.8T  0 disk 
    `-vda1    254:1    0   1.8T  0 part /etc/hosts
                                        /etc/hostname
                                        /etc/resolv.conf
    vdb       254:16   0 606.5M  1 disk 
    nbd8       43:256  0     0B  0 disk 
    nbd9       43:288  0     0B  0 disk 
    nbd10      43:320  0     0B  0 disk 
    nbd11      43:352  0     0B  0 disk 
    nbd12      43:384  0     0B  0 disk 
    nbd13      43:416  0     0B  0 disk 
    nbd14      43:448  0     0B  0 disk 
    nbd15      43:480  0     0B  0 disk 
  3. Note the full device name of the target disk such as /dev/sda or /dev/nvme0n1 instead of a partition entry.

    Using a partition like /dev/sda1 instead of the whole disk omits the MBR region and produces an unusable backup for boot recovery.

  4. Back up the first 512 bytes from the selected disk into a regular file using dd.
    $ sudo dd if=/dev/loop3 of=/root/sg-work/mbr-backup/mbr-lab.bin bs=512 count=1
    1+0 records in
    1+0 records out
    512 bytes copied, 6.6375e-05 s, 7.7 MB/s

    Reversing the if and of parameters or pointing either one at the wrong device can overwrite the MBR or another disk region, which may prevent the system from booting.

  5. Check the backup file size to confirm that exactly 512 bytes were written.
    $ ls -l /root/sg-work/mbr-backup/mbr-lab.bin
    -rw-r--r-- 1 root root 512 Jan 14 08:46 /root/sg-work/mbr-backup/mbr-lab.bin

    A size of 512 bytes indicates that the full MBR sector, including partition table and signature, has been saved.

  6. Inspect the backup contents for recognizable strings such as the boot loader name.
    $ strings /root/sg-work/mbr-backup/mbr-lab.bin

    Some MBR backups do not contain readable strings; when present, identifiers such as GRUB indicate that boot code was captured correctly.

  7. Copy the backup file to external storage such as a USB drive or network share.
    $ cp /root/sg-work/mbr-backup/mbr-lab.bin /media/usb-backups/

    Storing backups on a separate device protects them from failures or accidental overwrites on the main disk.

  8. Record the source disk, backup file name, and storage location in notes or documentation for future reference.