The Master Boot Record (MBR) is the first section of a disk that helps load your operating system. It contains critical information about how the disk is partitioned and where the operating system is located. In Linux, the MBR is stored in the first 446 bytes of the disk. Any changes to your disk, such as installing a new operating system, can overwrite or delete the MBR. This can cause boot issues or prevent access to your other operating systems.

Creating a backup of the MBR is an important step to ensure that you can restore it if necessary. This is especially useful when you plan to modify your system. In Linux, you can easily back up the MBR using the dd command, which copies the exact bytes of the MBR to a safe location. Having this backup ensures that if something happens to the MBR, you can restore it quickly without reinstalling everything.

This backup should be stored securely on an external storage device like a USB drive. Keeping the MBR backup separate from the main disk helps protect your system from permanent boot failures. By creating a backup before any major system changes, you can safeguard your data and maintain access to all your operating systems.

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

  1. Open a terminal application.
  2. Identify the disk that contains the MBR you want to back up.
    $ lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    loop0    7:0    0   89M  1 loop /snap/core/7713
    loop1    7:1    0 54.6M  1 loop /snap/lxd/11964
    loop2    7:2    0 54.6M  1 loop /snap/lxd/11985
    loop3    7:3    0 88.7M  1 loop /snap/core/7396
    sda      8:0    0   20G  0 disk
    ├─sda1   8:1    0    1M  0 part
    └─sda2   8:2    0   20G  0 part /
    sr0     11:0    1  748M  0 rom
  3. Back up the first 446 bytes of the selected disk using the dd command.
    $ sudo dd if=/dev/sda of=/home/user/mbr.bak bs=446 count=1
    [sudo] password for user:
    1+0 records in
    1+0 records out
    446 bytes copied, 0.00140727 s, 317 kB/s
  4. Confirm that the backup has been created and inspect its contents.
    $ strings /home/user/mbr.bak
    ZRr=
    `|f	
    \|f1
    GRUB 
    Geom
    Hard Disk
    Read
     Error

    The backup is in binary format, but recognizable strings like GRUB suggest the MBR was copied correctly if you're using the GRUB bootloader.

  5. Save the backup file to an external storage device such as a USB drive.
Discuss the article:

Comment anonymously. Login not required.