Master Boot Record

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read this

Master Boot Record

Postby AK Dave on Wed Apr 01, 2009 5:46 pm

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:
Code: Select all
sudo gpart /dev/sda

Use gpart to write a new partition table (assuming you trust gpart):
Code: Select all
sudo gpart -W /dev/sda /dev/sda


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.
User avatar
AK Dave
Level 6
Level 6
 
Posts: 1042
Joined: Wed May 14, 2008 3:39 pm
Location: Anchorage, AK USA

Linux Mint is funded by ads and donations.
 

Re: Master Boot Record

Postby Husse on Sun Apr 05, 2009 8:41 am

Blank your MBR if you've buggered it up (EXTREMELY DANGEROUS COMMAND):

I cannot agree more - if you don't have a backup of your MBR or know the MBR by heart you've lost all content on that drive and need expert advice to get it back
Perhaps testdisk* can save you but I'm not sure
*You find testdisk in the repositories
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19710
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: Master Boot Record

Postby AK Dave on Tue Apr 07, 2009 2:25 am

gpart can fix it if you've royally buggered it up.

You'll need to blank it (see above), then use gpart to whistle up a new one (see above).
User avatar
AK Dave
Level 6
Level 6
 
Posts: 1042
Joined: Wed May 14, 2008 3:39 pm
Location: Anchorage, AK USA


Return to Installation & Boot

Who is online

Users browsing this forum: W3C [Validator] and 25 guests