Dual booting between Windows and Linux (on separate hard disks)

My personal desktop system is comprised of two separate operating systems. I dual boot between these.
Note, depending on how GRUB is configured on your system, your configuration file might be menu.lst, or grub.conf. These files are normally located in /boot, and are the ones that need to be edited for this guide.

Hardware:
2x 160 GB Seagate Barracuda Hard Disks in a software RAID-1 setup for Ubuntu Linux.
1x 80GB Western Digital Special Edition Hard Disk for Windows XP Media Center Edition.

Windows has its own bootloader called NTLDR that it uses.
Linux by today’s standards will use GRUB (instead of LILO).

There is no need to replace NTLDR at all. Some have even gotten NTLDR to boot Linux by copying off the first 512 bytes off of their Linux partition. There have also been some reports of problems with people who replace NTLDR and have complaining virus scanners. So its probably a good idea to leave it intact and alone.

We’ll cover GRUB here, since a lot of people like using it to boot.

Normally, dual booting is very simple if you have both Linux and Windows on the same disk (you simply specify the options in /boot/grub/menu.lst as such):

# The normal way to do it with Windows on the same disk
title Microsoft Windows XP
root (hd0,1)
savedefault
makeactive
chainloader +1

Where hd0 (/dev/sda) is the disk (you have to guess — more on that in a minute), and partition 2 (which is /dev/sda2 in `fdisk -l`).

It is a little different when you have Windows on a separate disk alltogether. My hard disks were setup as follows.

IDE Channel 0:
Seagate 160GB (Master)
Seagate 160GB (Slave)

IDE Channel 1:
CD/DVD Drive (Master)
Western Digital 80GB (Slave)

Now, GRUB numberings (hdX,X), are very different than what you will see in `fdisk -l`. I spent quite a bit of time wondering why (hd2,0) wouldn’t boot into Windows.

Update: Don’t want to go through the pain of partition hunt and peck? Try some of this Ruby code.

To figure out which one is your Windows partition, go through on the GRUB menu (by rebooting) and get a `c`ommand shell.
Try root(hd0,0) incrementing all the way up to 7 (hd0,1) (hd0,2) (hd0,3)..and see if you get something on the lines of “unknown, partition type 0x7.”

If you don’t, move on to the next disk until you get it, or an error message telling you that the disk doesn’t exist. (hd1,0) (hd1,1)..

When you get a partition type of 0x7, thats Windows NTFS.

The rest from here is simple. Windows will need be told that it is on the master hard disk, so that Windows will work properly (there are some reports of problems without this for some reason).

This is fairly easy in GRUB. Insert the following:

# For Windows thats on another disk
# (Replace ‘(hd1)’ with the drive that Windows is on for you)
# You may also want to put this at the bottom, since some automated grub editors will overwrite this entry when they’re used
title Windows XP
map (hd0) (hd1)
map (hd1) (hd0)
chainloader (hd1,0)+1

Save, and reboot.

Parts derived from UbuntuGuide.org and other sources.

5 responses to “Dual booting between Windows and Linux (on separate hard disks)

  1. strabes

    You don’t have to guess the partition name for grub. There’s a naming scheme. See this page: http://www.onedot.nl/tutorials/grub-naming-scheme

  2. Pingback: Converting GRUB entries (Linux) « Coding + computing = fun

  3. Doug

    As a newbe to Linux I edited grub as above and couldn’t boot to Linux.
    My hard drives are
    1x 120GB Samsung with opensuse 10.2 installed
    1x 250 Western digital sata drive, not configured with raid and Windows Xp installed
    I simply changed the grub to read
    title Windows
    rootnoverify (hd1)
    chainloader (hd1)+1
    map (hd1) (hd0,1)
    Works wonders.

  4. michael

    how to choose which operating system(linux windows) to boot in.

  5. Great post. You could also use a virtual machine, though.
    OpenSUSE is great for business laptops, Ubuntu for home laptops, Fedora for stationary desktops, RHEL/CentOS for workstations and servers, and Mageia(successor to Mandriva) for home laptops and desktops.
    Do you use Steam? You can use Wine to play PC games and other Windows executables..
    Why not FreeBSD(GhostBSD or TrueOS), NetBSD, or the illumos distribution OpenIndiana? Illumos is the open-source version of Sun (now Oracle) Solaris, which is a great OS.
    There’s also Plan 9 and its successor Inferno from Bell Labs.
    I have a post here: https://worldconcernsblog.wordpress.com/computing/how-to-multi-boot-windows-linux-and-or-unix/?frame-nonce=69a5a7f38b

Leave a comment