The Master Boot Record (MBR) is the initial section of a disk that handles bootloaders, such as GRUB, to enable your system to boot into an operating system. It's crucial to maintain an MBR backup, as GRUB can be re-generated if lost or deleted.

To restore the MBR, you'll need to use dd, a command-line tool that can also create backups. If your Linux system is unbootable, you must use a secondary system, such as an Ubuntu installer disk, to load and restore your MBR backup.

Steps to restore Master Boot Record from dd backup:

  1. If your system won't boot, use a Live CD or USB drive to access Linux.
  2. Open the terminal.
  3. Verify that 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��D@�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
  4. List the available disks and find the one with the damaged master boot record.
    $ lsblk
    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. Use dd to restore the disk's master boot record from the backup.
    $ 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. Confirm that your MBR has been properly restored.
    $ sudo head -c 446 /dev/sda
    �c������t��pt���y|1��؎м ��d|<�t��R��t��}��|�A��U�ZRr=��U�u7��t21��D@�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
  7. Restart your system to ensure it's functioning correctly.
Discuss the article:

Comment anonymously. Login not required.