How do I dual boot Ubuntu and XP using entirely different disks?
September 30, 2006 6:57 AM   Subscribe

How do I dual boot Ubuntu and XP using entirely different disks?

I have tried all the suggestions others have claiming that ubuntu will recognize XP and add it to GRUB, but it simply doesn't do so. It results in either "unable to start operating system" error, or it just loads XP as normal. I have tried using two partitions on the same disk, with XP installed first. I have tried using two partitions on different disk, XP installed first. I simply have no idea why this works for everyone else but grub/dapper drake is so stupid now. What I want is to have XP on the second drive (larger), linux on first drive, and have grub be a boot manager.

Can someone tell me how to actually do this, instead of "Load XP first, then Ubunutu and it will recognize it and add it to Grub" because that simply does NOT work apparently.
posted by torpark to Computers & Internet (6 answers total) 4 users marked this as a favorite
 
What I want is to have XP on the second drive (larger), linux on first drive, and have grub be a boot manager.

There might be your problem. XP has to be installed to your primary drive for this to work AFAIK. Which means you'll have to make your XP drive the primary, then install Ubuntu to the second drive.

Also, older BIOSes can't read beyond the 1024th cylinder of the primary HD, so boot managers can't read other partitions beyond that cylinder or on separate drives. You might check with your PC manufacturer and see if this is the case, and if so, if you can upgrade to a BIOS that will read both your HDs at boot time.
posted by middleclasstool at 7:15 AM on September 30, 2006


If you're really setting up a new machine (as opposed to adding Ubuntu to an existing machine where you have to preserve partitions and/or save data), you might want to try this:
  1. Install large drive as primary, small drive as secondary
  2. Create a small (~100MB) primary first partition on the large drive
  3. Create a second partition on the large drive to hold XP
  4. Install XP (this will mark the second partition active)
  5. Install Ubuntu. Tell it that the small partition on the large drive is your "/boot" partition. After Ubuntu is installed, the boot partition will be marked active, so GRUB will get control. From the GRUB menu, you should be able to start XP also.

posted by spacewrench at 7:30 AM on September 30, 2006


Why not just download the free VMWare server and then install Ubuntu into it? It's a great way to test out different flavours of linux.
posted by fcain at 7:44 AM on September 30, 2006


This is a bit painful to do, but you can use XP's bootloader to run GRUB, rather than use GRUB to run XP. This solution is a little involved... it's not HARD, but it takes a number of steps. Other people may know GRUB better than I do, and may give you an easier/faster way. If you don't get one, though, this should work.

NTLDR (XP's bootloader) has the ability to run arbitrary programs, so you can extract the GRUB bootloader as a file, put it on your XP drive, and then add that file as a boot option in XP. So, XP becomes your boot manager.... you choose either Windows (which boots normally) or the 512-byte GRUB file, which will boot Linux.

This is an old tutorial on how to do this with LILO. I'd just use that for reference if you get confused; I'll try to describe here how you'd do it with GRUB.

First... it's MUCH easier if XP is on the primary drive, and boots completely from there. If you want the bootloader to be on a different disk than XP, it's more complicated, and I won't get into that here... covering all the possibilities would be a full article, and this is already very long as it is. I will assume that you have XP on the primary drive, and Linux on the second drive. (this is generally how most people set it up anyway, because Linux doesn't give a rat's arse where it runs from, and NT/XP can act a little wonky about drive lettering sometimes.)

During your Linux install, choose not to install a bootloader on the primary drive... that will erase NTLDR, which you don't want. Tell the system, instead, to install the bootloader in /dev/hdb (or hdc if the two drives are on separate channels.) hda should be Windows; Linux will be hdb or hdc, and your CDROM will be hdb or hdd, generally. If you're on SATA, the drives will most likely be sda and sdb, and the CD will usually be hda or hdc. You want to install GRUB on the boot sector of the Linux drive, not the Windows drive. If you get this wrong, you will render Windows difficult to boot.

Now you have to get that boot sector off the drive and into a file. This is probably easiest if you just boot up a Linux LiveCD of some kind. If you're installing from Ubuntu's LiveCD, I imagine that would work fine. To transfer the data to the XP partition, you'll also want a floppy disk.... you can't write to NTFS from Linux, and XP can't easily read any of the linux filesystems. So format a DOS floppy in XP.

Boot onto the LiveCD and mount your floppy:

mkdir /mnt/floppy (this is just in case)
mount -t vfat /dev/fd0 /mnt/floppy

Now, extract the bootsector:

dd if=/dev/hdb of=/mnt/floppy/bootsect.lnx bs=512 count=1 (substitute your Linux drive for /dev/hdb... possibilities discussed above.)

That will write the first 512 bytes from the bootsector onto the floppy as a file called 'bootsect.lnx'.

Unmount the floppy:

umount /mnt/floppy

Wait for the drive light to go out before removing the disk, and then reboot back into XP. Copy the bootsect.lnx file to your C:\ drive.

Edit the (hidden) C:\boot.ini file, and add this line at the end:

C:\bootsect.lnx="Ubuntu"

Save the file and reboot. When XP starts, you will get a prompt of what OS to start, rather than the old instaboot. If you choose Ubuntu off the menu, NTLDR will run GRUB, which *should* then boot your Linux kernel.

The nice thing about GRUB is that if you change kernels, it will just figure it out. With LILO, you had to redo this entire process every time you changed kernels, because it hardcoded the kernel's location on disk. If you updated kernels, you had to update this file. Big PITA. With GRUB, you should only have to do it once, as long as you don't move your disks around.

One last comment, before you do anything: if you put the XP disk first, and the Linux disk second.... the original Ubuntu installer may just figure out how to get GRUB working as your primary bootloader. Possibly worth a try. It sounds like you may have tried that already, but I thought I'd mention it just in case.
posted by Malor at 8:30 AM on September 30, 2006 [1 favorite]


A bit of clarification: The drive letters hda through hdd are used for the older PATA hard disks; they plug in with a wide, 40-pin connector. The newer SATA adapter uses a very small, narrow connector without visible pins.

Normally you will have two PATA adapters on your motherboard. Each adapter supports up to two hard drives. One is "master", and one is "slave". So Linux assigns drive names like this:

hda: primary master
hdb: primary slave
hdc: secondary master
hdd: secondary slave

If you pay attention to where the drives are connected, and whether they are master or slave, you will instantly know which hd name they have. Your BIOS will list your drives in order, so you can verify which adapter they're plugged into.

SATA can have all sorts of differnt configurations, but normally they will be assigned names in the order they're plugged in; the first connector is generally sda, and later ones are sdb and higher. Generally, the BIOS trick will also work here.... the order that drives show up in the BIOS is usually the order they'll show up in Linux. (It doesn't have to be this way, but it usually is.)

There are only a couple of SATA CD drives on the market; nearly all of them are old-style PATA. So the CD will almost always have one of the hd names. The most common option is "master device on the secondary controller", or hdc. hdb and hdd are also used sometimes. hda is possible, but quite rare. (usually the hard drive is there.)
posted by Malor at 11:37 AM on September 30, 2006


Try editing the windows section of your /boot/grub/menu.lst (on the Linux partition) to look like this:


title Microsoft Windows XP Home Edition
root (hd1,0)
savedefault
makeactive
map (hd0) (hd1)
map (hd1) (hd0)
chainloader +1


The root and map lines are key here; root tells GRUB which partition to boot, map pulls a switcheroo in the BIOS so WIndows sees the second drive as C:, and chainloader tells GRUB to pass control to WIndows' bootloader rather than try to boot a Linux kernel. I have no idea what, if anything, savedefault and makeactive actually do.

This is assuming your Linux drive is the master on the first ATA connector and the Windows one is the slave on that connector. Having said all that, though, Ubuntu successfully set up my system this way automatically, so I have no idea why it isn't doing so for you.
posted by arto at 7:35 PM on September 30, 2006


« Older The duck goes quack quack   |   How old is my AIM screen name? Newer »
This thread is closed to new comments.