Had to re-install Windows XP on my PC configured for Win XP-Ubuntu dual boot. While Windows XP overwrites the Ubuntu boot menu during re-installation, a re-installation of Ubuntu can be avoided if the Master Boot Record (MBR) is backed up prior to Win XP re-installation and mapped back after Win XP has been successfully re-installed. There are many forum discussion on how to back up the MBR using Ubuntu Terminal. The command to save the MBR (from Ubuntu Terminal) is
$ sudo dd if=/dev/sda of=/path/to/save/mbr.image count=1 bs=512
For SATA hard drive, Ubuntu will identify the first hard drive as sda. But if you are using IDE, then it will be hda. List the /dev directory to check.
$ cd /
$ cd dev
$ ls
Note that if you have partitioned your hard disk, the partitions are identified in the /dev directory as sda1, sda2 and so forth. But these are not relevant to the dd command. What you need to back up is first 512 kb of sda, use the above command as it is, adjusting only for the (i) hard disk type and (ii) the target path.
After completing the Win XP re-installation, start up the PC with a Ubuntu LiveCD. From Ubuntu terminal, overwrite the MBR with the backed up image:
$ sudo dd if=/path/to/save/mbr.image of=/dev/sda count=1 bs=446
Only the Boot Code contained in the first 446 kb (out of 512 kb) needs to be copied to recover the boot menu. The next 64 kb is the Partition Table and the last 2 kb (out of 512kb) is the Boot Code Signature.
And if for whatever reason, the wrong MBR image was backed up, all is not lost. This happened to me. I mistakenly backed up sda1 instead of sda. What I did was to use the MBR from another PC that is similarly configured for Win XP and Ubuntu dual boot. Copied the first 446kb as above and it worked for me!
Thursday, November 12, 2009
Subscribe to:
Posts (Atom)