Excellent article in April 2009 of Linux Journal (
www.linuxjournal.com) on restoring the MBR.
Link for subscribers here:
http://www.linuxjournal.com/article/10385
A few extracts:
Backup your MBR:
Code: Select all
sudo dd if=/dev/sda of=mbr_backup bs=512 count=1
Restore your MBR:
Code: Select all
sudo dd if=mbr_backup of=/dev/sda bs=512 count=1
Blank your MBR if you've buggered it up (EXTREMELY DANGEROUS COMMAND):
Code: Select all
sudo dd if=/dev/zero of=/dev/sda bs=512 count=1
Most of the article from there on has to do with use of and interpretation of results from 'gpart'. Not 'gparted', but 'gpart'. Short for "Guess Partition".
View the gpart version of your partition table:
Use gpart to write a new partition table (assuming you trust gpart):
Obviously the first step should be creating a good backup. Since it is simple to create a backup of your MBR, and simple to restore, it should be a no-brainer to do so. But fixing these sorts of problems requires being able to boot the computer from an alternate media source that will allow you to do this work. For this reason, I keep Knoppix on a thumbdrive. It has dd and gpart, as well as scads of other nifty tools. There is ample room on that Knoppix stick for backups of important files, like shared keys and MBR images. Never know when one of those might come in handy.
Destroying the MBR is something that could happen to anyone. Unfortunately.
Fixing the MBR should be well within the reach of anyone. Fortunately.