Back to Multiboot

Michael Ward's Guide to using GRUB

The GRand Unified Boot Loader


Contents

What is GRUB?
Where do I get GRUB?
Making a GRUB boot floppy/CD/DVD
Using GRUB - installing DOS 6.22,
   Win98, Win2000, and WinXP on one computer
The GRUB Configuration file
The GRUB boot menu
Drive and Partition Names
Dealing with Multiple Hard Disks


GRUB Tutorials

My instructions are brief and general. For more detail, try one of the many GRUB tutorials:

http://www.gnu.org/software/grub/manual/grub.html
http://www.linuxselfhelp.com/gnu/grub/html_chapter/grub_1.html
http://www.yolinux.com/TUTORIALS/LinuxTutorialRecoveryAndBootDisk.html#GRUB
http://www.linuxjournal.com/article/4622
http://www.linuxplanet.com/linuxplanet/tutorials/5361/1/
http://www-128.ibm.com/developerworks/edu/l-dw-linuxgrub-i.html
http://www.linux.com/howtos/Clone-HOWTO/booting.shtml


What is GRUB?

GRUB is a small, FREE program that controls the booting of a computer. You can use it to install and boot multiple Operating Systems on one computer. You can use it to manipulate a partition table on the fly, hiding/unhiding partitions, or re-ordering them.

GRUB (or grub) is potentially complex: it is very powerful and versatile, but the basics aren't hard to grasp. It can run from a hard disk, or floppy, or bootable CD/DVD.

Where do you get GRUB?

GRUB comes with most versions of Linux, or you can get it from the developers' web site (see below).

If you already use Linux, likely your boot loader is either GRUB or LILO. You can generally change/configure the boot loader by means of some GUI configuration tool in some equivalent to Control Panel. For example, in Mandrake, go to Start > System > Configure > Configure your Computer > Boot > Boot Loader. That takes you to the boot loader section of the Mandrake Control Centre. Check the documentation for your distro.

GRUB for Linux

Developers' web site: http://www.gnu.org/software/grub/

If GRUB is not installed at all, try installing it manually after the main installation - it shouldn't be difficult. Find out what software management tool there is for your distro. Or, you can just browse the installation CDs and look for a file(s) called grub*.*. Double-click on it and follow the directions. Or, you can go to the developers' web site: http://www.gnu.org/software/grub/, download GRUB and follow their installation instructions.

GRUB for Windows

Developers' web site: http://www.geocities.com/lode_leroy/grubinstall/

Yes, there is now a GRUB for Windows, at http://www.geocities.com/lode_leroy/grubinstall/. It should run fine from any FAT (16 or 32), or NTFS partition. It has to reside on drive C: (the first partition of the Primary Master), or it will not work properly. There is also a GUI configuration tool that runs within Windows; nice feature, but you still have to know a few grub commands and their syntax.

Making a GRUB boot floppy/CD/DVD

If you want to make it on your own, go for it. You'll find instructions in the tutorials listed above. It's not that difficult.

But, if that looks too scary, I can email you a 1.44Mb disk image (edit the address accordingly). You can use it to make a boot floppy or bootable CD/DVD.

Back to Top

Using GRUB - a sample scenario

Starting with a single blank hard drive

  1. Boot from a floppy or CD/DVD and create a Primary DOS partition (drive C:)
    but DO NOT CREATE ANY OTHER DRIVES OR PARTITIONS
  2. Install the OS as usual, e.g. DOS 6.22 (give it 20Mb)
  3. boot from a grub floppy/CD
  4. Press c to drop to the grub command line
  5. type this, then press Enter:

hide (hd0,0)

The drive C: created above is now invisible.

  1. Reboot from a floppy or CD/DVD and create another Primary DOS partition;

NOTE: this will appear to be drive C:. I know, you're thinking it should be D:. The first drive C: is presently invisible. We will create and hide more C: drives.

  1. Install the OS as usual, e.g. Windows 98 (give it 1Gb)
  2. boot from a grub floppy/CD
  3. Press c to drop to the grub command line
  4. type this, then press Enter:

hide (hd0,1)

  1. Reboot from a floppy or CD/DVD and create another Primary DOS partition; NOTE this will now appear to be drive C: (I know, you're thinking it should be E:)
  2. Install the OS as usual, e.g. Windows 2000 (give it at least 2Gb)
  3. boot from a grub floppy/CD
  4. Press c to drop to the grub command line
  5. type this, then press Enter:

hide (hd0,2)

  1. Reboot from a floppy or CD/DVD and create another drive; NOTE this will now appear to be drive C: (I know, you're thinking it should be F:)
  2. Install the OS as usual, e.g. Windows XP (give it at least 2Gb)

Here is a Map of the Partitions:

Drive Letter
You Expect
What GRUB
Calls It
Operating
System
Size
C: (hd0,0) DOS 6.22 20Mb
D: (hd0,1) Win 98 1Gb
E: (hd0,2) Win 2K 2Gb
F: (hd0,3) Win XP 2Gb

Back to Top

Booting the different Operating Systems

What you have done is create four Primary Partitions. To boot any operating system, you give GRUB a series of commands, either manually, or in a configuration file (see below).

You first have to hide the three partitions that will not be used. DOS/Windows can only understand one Primary Partition per hard disk. None of the OSes will be aware that the other three exist. Here are the commands to use at the grub command prompt. If the makeactive command gives an error message about an "Invalid device", ignore it.

FIRST boot from your GRUB disk, and press "c" to get a command prompt.

To boot DOS 6.22:

unhide (hd0,0)
hide (hd0,1)
hide (hd0,2)
hide (hd0,3)
rootnoverify (hd0,0)
chainloader +1
makeactive
boot

To boot Windows 98:

hide (hd0,0)
unhide (hd0,1)
hide (hd0,2)
hide (hd0,3)
rootnoverify (hd0,1)
chainloader +1
makeactive
boot

To boot Windows 2000:

hide (hd0,0)
hide (hd0,1)
unhide (hd0,2)
hide (hd0,3)
rootnoverify (hd0,2)
chainloader +1
makeactive
boot

To boot Windows XP:

hide (hd0,0)
hide (hd0,1)
hide (hd0,2)
unhide (hd0,3)
rootnoverify (hd0,3)
chainloader +1
makeactive
boot

Back to Top

What does that stuff mean?

hide/unhide hide or unhide a partition
rootnoverify tells GRUB what partition an OS lives on;
the "noverify" part doesn't concern us here
chainloader +1 pass control to the boot record on that partition
makeactive make that partition active
boot boot it

Sometimes the boot line can be omitted, but I've never seen a good explanation of when you can leave it out; I always include it.


NO, you DON'T have to type all that every time

The GRUB Configuration file:
  menu.lst  OR  grub.conf

Of course, you don't want to have to type all that every time. Save it in a file called menu.lst (that's MENU.LST, lowercase). Alternatively, you can call the file grub.conf, if you wish. Either will work. Use one or the other, not both.

The menu.lst file (or grub.conf) is grub's configuration file, which it reads every time it boots. In Linux or Unix its location is generally:

/boot/grub/menu.lst   OR   /boot/grub/grub.conf

In DOS/Windows, it has to be:

c:\boot\grub\menu.lst    OR   c:\boot\grub\grub.conf

Drive C: can be FAT16, FAT32, or NTFS.


Here is a sample menu.lst, with the above commands incorporated. Note that there are some other lines, for a few default settings and the menu labels. Any line beginning with # is a comment, and grub will ignore it. By default, this configuration will boot to DOS after 30 seconds. Entries start at 0 (zero). If that doesn't work for some reason, try the next entry (fallback 1). The grub menu will be white text on a blue background. This file must be plain text (ASCII). Don't use MSWord or WordPerfect etc. Use a plain text editor like Notepad. Lines beginning with # are comments.

# The main GRUB configuration file,
# /boot/grub/menu.lst (Linux, Unix)
# or c:\boot\grub\menu.lst (DOS/Windows)
# Sample boot menu configuration file

timeout 30
default 0
fallback 1
color=white/blue

# this is entry 0, the default
# To boot DOS:
title DOS 6.22
unhide (hd0,0)
hide (hd0,1)
hide (hd0,2)
hide (hd0,3)
rootnoverify (hd0,0)
chainloader +1
makeactive
boot

# this is entry 1
# To boot Windows 98:
title Windows 98
hide (hd0,0)
unhide (hd0,1)
hide (hd0,2)
hide (hd0,3)
rootnoverify (hd0,1)
chainloader +1
makeactive
boot

# this is entry 2
# To boot Windows 2000:
title Windows 2000
hide (hd0,0)
hide (hd0,1)
unhide (hd0,2)
hide (hd0,3)
rootnoverify (hd0,2)
chainloader +1
makeactive
boot

# this is entry 3
# To boot Windows XP:
title Windows XP
hide (hd0,0)
hide (hd0,1)
hide (hd0,2)
unhide (hd0,3)
rootnoverify (hd0,3)
chainloader +1
makeactive
boot

Back to Top

The GRUB boot menu

When you boot, you should see something like this for the bare-bones versions of GRUB. Some versions look quite different, with full-screen graphics for backgrounds.

The white text on a blue background is specified by the line color=white/blue. The line default=0 means the first entry is the default; it should be highlighted:



NOTES

Back to Top

Names of Drives and Partitions used by DOS/Windows, Linux, and GRUB:

Primary Partitions DOS/Win Linux GRUB Notes
Primary Partition 1 C: /dev/hda1 (hd0,0) 1st part. on Pri. Master
Primary Partition 2* N/A /dev/hda2 (hd0,1)  
Primary Partition 3* N/A /dev/hda3 (hd0,2)  
Primary Partition 4* N/A /dev/hda4 (hd0,3)  
Extended Partition -- /dev/hda2 (hd0,1) not a "drive" by itself
Partition 1 D: /dev/hda5 (hd0,4)  
Partition 2 E: /dev/hda6 (hd0,5)  
Partition 3 F: /dev/hda7 (hd0,6)  
Partition 4 G: /dev/hda8 (hd0,7)  

*NOTE If Primary Partitions 2, 3, and 4 don't exist, then /dev/hda2 and (hd0,1) will refer to the entire Extended Partition. In that case, hiding (hd0,1) will hide the entire Extended Partition and all drives (partitions) within it.

Standard Drive Designations

BIOS Name Linux GRUB
Primary Master /dev/hda (hd0)
Primary Slave /dev/hdb (hd1)
Secondary Master /dev/hdc (hd2) or (hd1); see below
Secondary Slave /dev/hdd (hd3) or (hd2) or (hd1); see below

NOTES


Dealing with multiple drives

If there is a second hard drive, then it's Primary Partition will be drive D: to DOS/Windows. Let's take as an example a system with two drives, a Primary Master and Secondary Master, each with three partitions.

Drive Partition DOS/Win Linux GRUB
Primary Master 1 (Pri) C: /dev/hda1 (hd0,0)
  2 (Ext) E: /dev/hda5 (hd0,4)
  3 (Ext) F: /dev/hda6 (hd0,5)
Secondary Master 1 (Pri) D: /dev/hdb1 (hd1,0)
  2 (Ext) G: /dev/hdb5 (hd1,4)
  3 (Ext) H: /dev/hdb6 (hd1,5)

NOTES

Graphical Representation

Single Hard Disk, Three Partitions

single hard disk with three partitions

Two Hard Disks, Three Partitions each

two hard disks, three partitions each
Back to Top
Back to Multiboot

Copyright © Michael Ward 1999 - 2008