Gasp! Dual-booting with Windows XP!

Because of my previous confession, it is with deep embarrassment that I admit that, yes, I am now dual-booting my office computer between Ubuntu and Windows XP. I feel so...tainted. All that gives me comfort now is the thought that I still use Ubuntu 95% of the time and only switch to That Other Operating System when I need a quick gaming fix.

I suppose I reached this stage because, after my last encounter, I just couldn't let the idea go. I wondered why Windows XP wouldn't install on my system. I guessed that it might have been because the disk I was installing on was SATA, and apparently that is indeed the case. Installing Windows XP on a SATA hard disk needs a driver on floppy, and without a floppy, it means additional contortions with nLite.

Who ever said installing Windows was easy?

As it turns out, I did have an old IDE hard disk already installed on my computer. I didn't need to create my own Windows XP installation disk anymore. The IDE only held backup data, and I moved that off to another hard disk. When I attempted the Windows XP installation with the 40GB IDE as a target, XP finally recognized the hard disk.

Installing Windows XP was every bit as painful as I remembered and imagined it to be. Copying files took interminably long, drivers had to be found, and it took several reboots to install all of them. That actually gave me some more appreciation for Ubuntu and its frequent release cycle -- but I'll cover that in a later post.

Along the way, I learned a couple of things about GRUB and booting that otherwise would have escaped my attention. If nothing else, this was worth the pain of the transition process.

To understand the situation, I have to explain my setup. Here goes:

I have three hard disks on my computer: a 160GB SATA hard disk (for Ubuntu), a 500GB SATA hard disk (for data), and an old 40GB IDE hard disk, as previously mentioned. My BIOS allows me to select which of the disks to boot from.

Originally, my system was set to boot from the 160GB hard disk. To install Windows XP, I had to switch to the 40GB IDE hard disk as the primary boot disk. Otherwise, XP will try (and fail) to overwrite MBR of the 160GB hard disk. Besides, I didn't want to have to muck with my already working Ubuntu system.

So, with all the attendant pains, I managed to get Windows XP on the 40-GB hard disk.

After installing XP, I switched the primary hard disk back to the 160GB SATA. With bated breath, I waited for the Ubuntu splash screen to come up...and there it was! Hooray!

Now I knew I could get GRUB to recognize and boot to the Windows XP hard disk. I added the following lines to the bottom of /boot/grub/menu.lst:

title Windows XP
rootnoverify (hd2,0)
chainloader +1

I was already reasonably sure that the disk was on the designated drive. However, after I selected Windows XP on the GRUB menu, the system would just hang. Booting to the Ubuntu partition worked perfectly fine, though. I thought it might have had something to do with the hard drive selection, so I tried the other two combinations, hd0 and hd1, but both resulted in errors.

After much head-scratching, it turned out what I actually needed to add was:

title Windows XP
rootnoverify (hd2,0)
map (hd2) (hd0)
chainloader +1

The line map (hd2) (hd0) tells GRUB to present hd2 to Windows XP as if it were hd0. This is because when I installed Windows XP, the 40GB hard disk (now hd2) was the primary (hd0). Therefore I needed this bit of trickery to fool XP.

As per the GRUB manual:

map maps the drive from_drive to the drive to_drive. This is necessary when you chain-load some operating systems, such as DOS, if such an OS resides at a non-first drive.

makeactive performs a supplemental function. It set the active partition on the root disk to GRUB's root device. This command is limited to primary PC partitions on a hard disk.

After these changes, I finally got the system to dual boot. But it sure took a long time.

Sigh. Who ever said installing Windows was easy?