Hack:   Hack the Windows NT/2000/XP Boot Loader
Subject:   XP on First Hard Drive and Installed Ubuntu 6.1 to Second Hard Drive
Date:   2006-11-13 20:10:04
From:   JJS1971
I'm also very new to Linux and have spent the last several days trying to configure a Dual Boot with Windows XP and Ubuntu 6.1. Below is a summary of my experience thus far - I can at least boot to both XP and Linux, but I still have to use my BIOS to do so.

As the title of my post suggests, I have 2 IDE hard drives - XP was already on the master hard drive and I wanted (and have more or less succeeded) to install Ubuntu 6.10 LiveCD distribution on the slave. My primary goal at the outset was to leave my Windows XP installation untouched - including hands off the MBR - and use the Windows NTLDR to dual boot XP and Linux.

I booted from the Ubuntu LiveCD version and ran the install program. I opted to manually partition the hard drives - namely leave my Windows XP drive (identified as hda by the installer) alone and install the Ubuntu 6.1 distribution to the slave drive (identified as hdb).

During the installation process, the partition tool (gparted) was I believe Step 4 or 5. I first made sure to switch to hdb. (The partition tool defaults to hda - which I didn't want as my goal was to leave the Windows XP drive untouched.) AFTER selecting hdb, right or wrong, I proceeded to create a 256 MB ext2 format boot partition to mount /boot as the first partition of the slave hard drive, a 55 GB ext3 partition as the second partition to mount root (/), a 16 GB vfat partition for sharing files between Linux and XP, and a 4 GB ext3 Linux-swap partition. So, the drive geometry of my second (slave) hard drive was:

Partition 0 ext2 (256 MB) hdb1
Partition 1 ext3 (55 GB) hdb2
Partition 2 vfat (16 GB) hdb3
Partition 3 Linux-swap (4 GB) hdb4

In the next step, I then assigned the mount points as:

/boot --> hdb1
/ --> hdb2
/media/hdb3 --> hdb3
swap --> hdb4

Finally, prior to the last step - and VERY IMPORTANT - the Ubuntu installer wanted to install GRUB to hd0 (0 implies first hard drive) - namely, the MBR of my master hard drive with Windows XP. But, again, I wanted to leave that drive alone so I had Ubuntu install GRUB to hd1 (a.k.a., hdb).

The installation was successful and at the end I selected "Continue to Run from CD" because since I left hda alone, I still needed a copy of the first 512 bytes of hdb for the Windows NTLDR to reference.

I then noticed however that I had to go back into Windows to format the vfat partition - the Ubuntu install didn't seem to do that - maybe I did something wrong, but I rebooted back to Windows (which still worked because I did not touch hda during the Ubuntu installation) and formated the vfat partition with the Windows Disk Management Tool. Then I rebooted to the Ubuntu LiveCD.

So, following numerous other examples on the web, I then proceeded to get a copy of the first 512 bytes of hdb. I ran from a Terminal:

sudo gedit /etc/fstab

and added the lines:

/dev/hdb1 /media/hdb1 ext2 rw,exec,sync 0 0
/dev/hdb3 /media/hdb3 vfat rw,exec,sync 0 0

I saved the result and went back to the Terminal screen and ran mkdir commands to establish the mount points:

sudo mkdir /media/hdb1
sudo mkdir /media/hdb3

and then mounted the devices:

sudo mount /dev/hdb1
sudo mount /dev/hdb3

and ran:

sudo dd if=/dev/hdb1 of=/media/hdb3/bootsect.lnx bs=512 count=1

Then, I quit and rebooted to windows, copied bootsect.lnx from the vfat partition to C:\bootsect.lnx and added the line

c:\bootsect.lnx="Ubuntu 6.10 Linux"

to my boot.ini file. Then I rebooted. I then had two options to boot:

Windows XP
Ubuntu 6.10 Linux

Windows still worked! and picking Ubuntu 6.10 Linux on a subsequent reboot loaded GRUB.....but not quite....I had what seems to be the well-established GRUB _ error - nothing worked but Ctrl-Alt-Del. So, I was mystified. Finally reading another post on this website (by pjo - Thank You!) with regard to the Suse Installer finally led me to try something. I went into my BIOS and switched the boot order of my hard disks - first boot from the slave. This bypasses NTLDR (actually the startup never sees it) and brought me to the GRUB boot menu! I then selected the Linux kernel to boot, but I got "Error 17: Cannot Mount Selected Partition". I then exited out to a grub command prompt and ran two commands:

grub> geometry (hd0)


grub> geometry (hd1)

Very interesting was the result. Perhaps because I switched the boot order, GRUB now identified hd0 as my slave drive and my master NTFS drive as hd1. So, I rebooted to the Ubuntu LiveCD, mounted my slave boot partition (as above), cd to /media/hdb1, and did:

sudo gedit /grub/menu.lst

I then replaced all references to (hd1,0) with (hd0,0) in this file and similarly I did:

sudo gedit /grub/

and mapped (hd0) to (hdb) (and deleted the default mapping from (hd0) to (hda)).

Then rebooted again. The good news is that now I'm able to boot Ubuntu 6.1 from the slave so long as I switch the BIOS to boot from the slave first. Unfortunately, I'm still not able to use NTLDR successfully to chain to GRUB. When I go back to booting from the master hard drive (and no matter if I switch my and menu.lst files back it seems), I still have the GRUB _ error. Still a mystery to me. Maybe another week for that. I'm thinking there is a problem perhaps with bootsect.lnx, but not sure really where to look to find answers.