when windows wipes teh MBR
- February 7th, 2009
- Posted in Linux . Windows
- By Jason Zerbe
- Write comment
I installed Windows XP Home on some leftover space on one of my CentOS OpenVZ machines that I use for development purposes. It is nice to have a ready to go system for when friends come over and we get to hankering for some LAN gaming. So install my Windows to the leftover space and of course it wipes the Master Boot Record. Bah! So I get out my CentOS install disk and type in “linux rescue” at the install prompt. From there I was kind of lost, so I searched around and found a short guide to restoring the GRUB boot loader. After that everything was smiles.
My process:
- Get a linux install disk and type “
linux rescue” at the install prompt - The rescue process should mount any of the found linux systems. (It did in my case.) The rescue process mounted my linux installation to “
/mnt/sysimage“. I then chrooted into my system: “chroot /mnt/sysimag“. - My main hard drive in said machine is named “hda”, so I reinstalled GRUB to /dev/hda with the command: “
grub-install /dev/hda“. My original GRUB configuration was restored successfully. - I then added the boot entry for the new Windows XP Home installation. I had installed it to the 3rd partition on the main hard drive so I added the following entry to my GRUB menu.lst file (/boot/grub/menu.lst).
title Windows XP Home
root (hd0,2)
savedefault
makeactive
chainloader +1(hd0,2) = (the first hard drive, 3rd partition). Thus, (hd0,0) would be the first hard drive and first partition.
- Just remember to exit the chroot’ed shell before you reboot. Otherwise everything we just did goes to pot.
And everything was working spiffy after that.
This happened to me again recently. When I going to use my Debian 5 netinstall disc to go through all of this command line junk, there was an option to repair the grub MBR entry within the rescue stage. All that I had to do was specify the partition of the root filesystem if I remember correctly.