Master Boot Record

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
AK Dave

Master Boot Record

Post by AK Dave »

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.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Husse

Re: Master Boot Record

Post by Husse »

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
AK Dave

Re: Master Boot Record

Post by AK Dave »

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).
Locked

Return to “Installation & Boot”