Multibooting with Grub
-A Short guide for the rest of us-

Let me start this whole thing by explaining that I am not an expert on Grub. Everything I know about Grub is on this webpage and I am providing this page as a service to others out there who have looked for help with Grub and only found this Mini-Howto which shall we say, leaves a lot to be desired for the common man. I was lost on what to try until I found this page (http://linux-sxs.org/grubtg.html) which lays it all out in an easy to read format.

So why, if this wonderful page already exists on linux-sxs.org, am I putting a small guide on the web? Am I just wasting space? Yes and no. Well I'd like to think I'm doing everyone a favor. If you search for grub on google, the linux-sxs.org page is about the 5th item on the 5th page. That's not encouraging considering that 90% of the other links are to the same mini-howto which I rate very low. Since this website is occasionally crawled by Google and other search engines, I hope to elevate a page I find helpful by linking to it, in the hopes that others will find it more quickly than I did. Since you are here, I might as well explain Grub to the best of my ability to help those in need. But if you need more information than what's provided here, check out the link above and you will probably find the answer (its really a neat page).

Get on with it Already!

So what is Grub? Grub is a bootloader that stands for GRand Unified Bootloader. Its a very diverse and flexible bootloader in that its capable of booting just about any operating system that I would ever dream of installing. So in my case, I installed Red Hat 7.2 and already had Windows 2000 installed on the first partition of the drive. The NT bootloader was overwritten with grub when I installed Linux and now I need to tell Grub that yes, I'd like to boot Windows on occasion

Before we begin, let me emphasize that you probably don't want to copy this stuff verbatim. Please read the entire document because the examples here are for a specific configuration (mine) and yours might be slightly different. The first step to mutli booting with Grub is t o figure out what is where. If you're like me and had a previous installation of Windows and then partitioned off some hard drive space for Linux you'll find that Windows is on hd0,0 (explained below) and Linux is on hd0,1. If you're also like me and added a second hard drive with Windows 98 you'll find that Windows 98 is located on hd1,0.

Grub uses a drive specification that is different than that of Red Hat 7.2. For instance you have two hard drives on your system

RH 7.2 says, /dev/hda and /dev/hdb in reference to hard drives one and two.
Grub says, hd0 and hd1 in reference to hard drives one and two.

Partitions start and 0 and go up. So Windows 2000 is on the first partition of the drive and is is located on hard drive 1 (hd0) and on partition 1 for the grand total of hd0,0.

That's Great, Now How do I Tell That to Grub?

Well it just so happens that Grub has a configuration file called menu.lst which in most installations of Linux is located in /boot/grub. When I started up Linux for the first time, mine looked something like this:

default = 0
timeout =10
splashimage=(hd0,1)/grub/splash.xpm.gz
title = Red Hat Linux
root = (hd0,1)
kernel /vmlinz-2.4.7-10 ro root=/dev/hda3
initrd /initrd-2.4.7-10.img

Basically ignore all of this. This is what gets Linux to boot up and you don't really want to change much (unless you update your kernel and need to specify the new one for some reason). You'll need to be root to edit this file and its a good idea to make a backup before you start:

bash[/boot/grub]$ cp menu.lst menu.lst.backup

Fire up your favorite text editor (I like pico) and we'll add the following lines to the end of the file for Windows 2000 (this should work for 95/98/ME as well).

title = Windows 2000
root = (hd0,0)
makeactive
chainloader +1

Save the file and reboot. When grub loads you should see a new option titled "Windows 2000" and it should boot right into 2000 when you hit enter. If you've made a typo or if you've specified the wrong partition you'll need to go back into this file (or edit it from grub but the changes won't be permanent).

What if I installed Linux first, and then Windows 2000?

This one could be a tuffy. Depending on how many Linux partitions you have it could be hd0,1 or it could be something like hd0,4. Since I have no first hand experience with this situation I wouldn't be able to say. My initial thought would be to try hd0,1 as the root for Windows (since Linux would be hd0,0) and if it doesn't work, edit your grub file and then try hd0,2 and so on. Its a little tedious but you should eventually find it. The other obvious answer would be to use fdisk to print your partition table but I don't want to explain how to use fdisk because its getting late.

What if I have Two Hard Drives with Windows on the Second?

This configuration involves a little trick. If you were too lazy to read the entire document you've probably already tried:

title = Windows 98
root = (hd1,0)
makeactive
chainloader +1

You've also realized that it doesn't work. Why is this? Its because Windows has to be on logical drive C, on a secondary hard drive this isn't possible by default. On some systems you can configure the BIOS to switch the logical drive configuration for you but you can do that more easily with Grub. Use the following entry:

title = Windows 98
root = (hd1,0)
map (hd0) (hd1)
map (hd1) (hd0)
makeactive
chainloader +1

The map option switches hd0 and hd1 and makes it appear that hd1 is the primary drive. So you should now have a starting point for most configurations. My finished menu.lst looks like this:


default = 0
timeout =10
splashimage=(hd0,1)/grub/splash.xpm.gz
title = Red Hat Lin ux
root = (hd0,1)
kernel /vmlinz-2.4.7-10 ro root=/dev/hda3
initrd /initrd-2.4.7-10.img

title = Windows 2000
root = (hd0,0)
makeactive
chainloader +1

title = Windows 98
root = (hd1,0)
map (hd0) (hd1)
map (hd1) (hd0)
makeactive
chainloader +1


I hope this page helps and if you need more in depth information or if you want instructions on getting Grub to boot other operating systems go to
http://linux-sxs.org/grubtg.html which should answer most questions. As I said above, this is the gist of my knowledge of Grub and I probably will not be able to answer questions about it, especially those of the nature of I have xxx configuration and it doesn't work what do I do. Nor do I know anything about compiling Grub or installing Grub.

However, if you do find a mistake on this page or if I've defined or explained something incorrectly, feel free to email me at webmaster@oculon.org

Updated 12/15/2002