How to backup MBR in Linux
MBR or Master Boot Record is a small program that defines how operating systems are loaded. It resides in the first 446 bytes of your boot disk. The MBR could be deleted or replaced when installing a new operating system such as Microsoft Windows, making you unable to boot into your other installed operating systems.
It makes it essential to backing up your MBR, especially before installing a new operating system. MBR could be backed up via Linux using dd at the terminal.
Steps to backup Master Boot Record from Linux:
Launch your preferred terminal application.
Check available disks and select the one with the MBR to backup.
$ 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
Backup the master boot record of the disk using dd to a file.
$ 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
Verify that the MBR is successfully backed-up.
$ strings /home/user/mbr.bak ZRr= `|f \|f1 GRUB Geom Hard Disk Read Error
The file is in binary format but you should be able to see some strings such as GRUB (if you're using GRUB as your bootloader) as hint that you've copied the right section of the disk.
Store the backup in other medium such as removable media for easy restoration in case of MBR corruption in the future.