The master boot record (MBR) is a very small program that contains information about your hard disk partitions and loads the operating system. This program is located in the first sector of the hard disk and is 512 bytes. If this file becomes damaged, the operating system cannot boot. Therefore, it is important to back up the MBR so that you can replace a damaged copy if needed. To make a backup of the MBR from the hard drive and store a copy to your /home directory, use the dd command. An example of such a backup command is:

dd if=/dev/hda of=~/mbr.txt count=1 bs=512

The preceding example assumes that your hard drive is /dev/hda. With this command you are taking one copy (count=1) consisting of 512 bytes (bs=512) from /dev/hda (if=/dev/hda) and copying it to a file named mbr.txt in /home (of=~/mbr.txt).

If you need to restore the MBR, you may use the following command:

dd if=~/mbr.txt of=/dev/hda count=1 bs=512

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.