Categories
Uncategorized

Thank you, dd for saving and restoring my MBR

I finally got around to upgrading my dual-boot desktop PC to running Windows XP.  It was just about time, the version of windows I was running was no longer supported and more and more software requires Windows XP nowadays.  I also wanted to start using my Windows partition for more than World of Warcraft and occasional IE6 Testing.  Mini-rant: One might think that, by now, Windows would play nicely if you are installing it on an existing dual-boot setup and not do rude things like naively overwrite your Master Boot Record.  If one thought that, however, one would be very naive indeed.

The common wisdom, when setting up a dual booth system, is to install Windows first, then your other operating systems, since the latter are smart enough to setup a menu at boot time to choose which OS to load.  That’s find advice for a fresh setup, but if you have an existing system you have to take one precaution that will save you time and headaches.  First, make sure you have some sort of Linux "Live" or Install CD that you can boot from after Windows is setup.  Second, before installing Windows, you’ll want to backup your MBR to some removable media, like a USB disk, so that you can restore it after Windows does its thing.

To backup your MBR, use the dd tool, keep in mind you’ll need to change the input and output files to reflect your own system:

dd if=/dev/sda of=/media/usb1/sda-mbr.bin bs=512 count=1

Likewise to restore it, boot your rescue disk, insert your flash drive and run the following to copy it back to the boot drive

dd if=/media/usb1/sda-mbr.bin of=/dev/sda bs=512 count=1

This worked for me, but it could be a bit more intricate. I followed the advice found here and here.