Notice!!

Please take time to visit us at out other sites:

www.wrightitdown.com

Home Site of Wrightitdown
blog.wrightitdown.com
Notes of The Wright Computer Services
fta.wrightitdown.com
Find Your FTA, Satellite needs here!
kennywright.wrightitdown.com
Personal Site of Lead Technician
twitter.wrightitdown.com
Follow us on Twitter!
urbanwritten.wrightitdown.com
Find Books You can Enjoy!!
facebook.wrightitdown.com
Become a friend of ours on Facebook!

Ubuntu Tips

Backing up the MBR (Master Boot Record) If you save copies of some or all ...

posted May 4, 2009 8:09 PM by Kenny Wright

Backing up the MBR (Master Boot Record)

If you save copies of some or all of your partitions individually, and want to be able to use them to restore a working system, you'll also need to backup and restore the MBR and partition table. (The same caveats apply as discussed above about whether partition tables can be restored onto a disk of a different size).

Backing up the MBR:

dd if=/dev/hda of=backup-of-hda-mbr count=1 bs=512

This stores the first 512 bytes of the disk (contianing the MBR and the primary partition info - i.e. the first four primary entries) into the file "bcakup-of-hda-mbr" which you can then copy to somewhere safe.

To restore (be careful - this could destroy your existing partition table and with it access to all data on the disk):

 dd if=backup-of-hda-mbr of=/dev/hda

If you only want to restore the actual MBR code and not the primary partition table entires, just restore the first 446 bytes:  dd of=/dev/hda if=backup-of-hda-mbr bs=446 count=1. (Those first 512 bytes are 446 bytes of MBR, then 64 bytes of primary partition table).

Backing up the extended partition table

sfdisk -d /dev/hda > backup-hda.sfdisk

(sfdisk is in the util-linux package. I think it's in Knoppix.)

Restore (ditto the above warning):

sfdisk /dev/hda <backup-hda.sfdisk

(then reboot)

 I also recommend making a record of the partition table details as displayed in whatever disk partitioning program you like to use, and also as displayed by fdisk -l. Could be handy if you find yourself needing to repartition the disk by hand in preparation for restoring some images of individual partitions.

1-1 of 1