[lug] Saving the Vista MBR before installing Linux: How many bytes is MBR?

D. Stimits stimits at comcast.net
Sat Aug 4 15:27:16 MDT 2007


siegfried wrote:

> I previously installed linux (debian) on a USB drive connected to an 
> XP Pro machine and accidentally wiped out my Windows XP MBR when I 
> installed GRUB.
>
> Now I am repeating that exercise with a new Vista Notebook computer. 
> What is the command to save the MBR should I accidentally wipe it (the 
> MBR) out again? I think it is some dd command but I don’t know how 
> long the MBR is.
>

Just getting to my email on the weekend...if you want to copy a boot 
record you're basically copying 1 block of 512 bytes. You can copy the 
MBR by naming the disk, or a partition boot record (PBR) by naming the 
partition. To back up the MBR of /dev/hda:
dd if=/dev/hda of=mbr.iso bs=512 count=1

To back up the PBR of /dev/hda1:
dd if=/dev/hda1 of=pbr.iso bs=512 count=1

If you want to verify it, you can look at it in a hex editor like 
khexedit, and the hex last 2 bytes should be "55 aa".

If you want to restore the boot record, reverse "if" and "of".

Note that these are bit by bit exact images, so if you put it on a 
floppy, it can't have any bad spots marked out, it has to be a "perfect" 
512 bytes.

D. Stimits, stimits AT comcast DOT net



More information about the LUG mailing list