MBR or Master Boot Record is the first section of a disk responsible for loading bootloaders such as GRUB. It enables your system to boot into an operating system; thus, keeping a backup of your MBR is essential. GRUB, on the other hand, can be re-generated if lost or deleted.

Master Boot Record can be restored using dd. It is a command-line tool also used to create the backup. If you cannot boot into your Linux system, you will need to boot up from a secondary system like an Ubuntu installer disk. From there, you can load up your MBR backup to restore.

Steps to restore Master Boot Record from dd backup:

  1. Boot into Linux using Live CD / USB Drive if you can't boot into your system.
  2. Launch terminal.
  3. Check if your MBR backup is correct.

    $ file mbr.bak  mbr.bak: DOS executable (COM) $ cat mbr.bak  �c������t��pt���y|1��؎м ��d|<�t��R��t��}��|�A��U�ZRr=��U�u7��t21��[email protected]�D��D�f�\|f�f�`|f�\ Z������}�f�ƈd�@f�D�������@�����f�f�`|f	�uNf�\|f1�f�4��1�f�t;}7����0�����Z�ƻp��1۸�r��`���1�������a�&Z|��}���}�4��}�.���GRUB GeomHard DiskRead Error ����<u��

  4. List available disks and identify the one with the corrupted master boot record.

    $ lsblk NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT loop0    7:0    0  55.4M  1 loop /snap/core18/1932 loop1    7:1    0  55.4M  1 loop /snap/core18/1944 loop2    7:2    0 217.9M  1 loop /snap/gnome-3-34-1804/60 loop3    7:3    0   219M  1 loop /snap/gnome-3-34-1804/66 loop4    7:4    0    51M  1 loop /snap/snap-store/498 loop5    7:5    0  62.1M  1 loop /snap/gtk-common-themes/1506 loop6    7:6    0    51M  1 loop /snap/snap-store/518 loop7    7:7    0  64.8M  1 loop /snap/gtk-common-themes/1514 loop8    7:8    0  31.1M  1 loop /snap/snapd/10492 loop9    7:9    0  31.1M  1 loop /snap/snapd/10707 sda      8:0    0    20G  0 disk  ├─sda1   8:1    0     1M  0 part  ├─sda2   8:2    0   513M  0 part /boot/efi └─sda3   8:3    0  19.5G  0 part / sr0     11:0    1  1024M  0 rom

  5. Restore the master boot record of the disk from the backup using dd.

    $ sudo dd if=mbr.bak of=/dev/sda [sudo] password for user:  0+1 records in 0+1 records out 446 bytes copied, 0.00284831 s, 157 kB/s

  6. Check if your MBR is correctly restored.

    $ sudo head -c 446 /dev/sda �c������t��pt���y|1��؎м ��d|<�t��R��t��}��|�A��U�ZRr=��U�u7��t21��[email protected]�D��D�f�\|f�f�`|f�\ Z������}�f�ƈd�@f�D�������@�����f�f�`|f	�uNf�\|f1�f�4��1�f�t;}7����0�����Z�ƻp��1۸�r��`���1�������a�&Z|��}���}�4��}�.���GRUB GeomHard DiskRead Error ����<u��

  7. Reboot your system to test.