Recipe 12.22. Backing Up the MBR

 < Day Day Up > 

12.22.1 Problem

You would like to have a backup copy of your master boot record. And what good is that backup if you don't know how to restore it?

12.22.2 Solution

You can back up the MBR to a floppy disk. Mount the disk first, using the mountpoint appropriate for your system, then use the dd command:

# dd if=/dev/hda of=/floppy/mbr bs=512 count=1

Restore it this way:

# dd if=/floppy/mbr of=/dev/hda bs=512 count=1

The filename of your backup can be anything you like: for example, /mbr-server01 labels it so you know which computer it belongs to. You can store many MBRs on a single floppy disk:

# ls /floppy lost+found  mbr-server01  mbr-workstation04  mbr-host15

If you need to format a floppy disk first, do this:

$ mke2fs /dev/fd0

This creates a nice Linux-formatted disk, using the Ext2 filesystem.

12.22.3 Discussion

The dd command does a literal, byte-by-byte copy. It doesn't need to understand filesystems, so it can be used to copy block devices, like /dev/hda.

If your system does not have a floppy drive, you can restore a borked MBR with a Knoppix disk, by reinstalling GRUB (Recipe Recipe 12.13).

12.22.4 See Also

  • dd(1), mke2fs(8)

  • Recipe 12.13

     < Day Day Up > 


    Linux Cookbook
    Linux Cookbook
    ISBN: 0596006403
    EAN: 2147483647
    Year: 2004
    Pages: 434

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net