The GRUB booter

This section discusses:

How to install grub

GRUB is a booter for your computer: It loads the kernel and gets the whole system running. (LILO is a different, older, boot loader with fewer features.)

Check to see if grub is installed on your system:

rpm -q grub
package grub is not installed
If you are told that grub is not installed, then install grub from either the Red Hat CD releases or from the Internet, such as: rpmfind. Then add the rpm:
rpm -i grub-0.92-7.i386.rpm

How to configure grub

Check to see if the /boot/grub directory exists on your system. The /boot/grub directory run NOT exist until you do the /sbin/grub-install command. Specify which disk that the GRUB boot loader should be installed on (/dev/hda in this case):
/sbin/grub-install /dev/hda
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

# this device map was generated by anaconda
(fd0)     /dev/fd0
(hd0)     /dev/hda

Below is a sample /boot/grub/menu.lst file that configures which kernel is booted (there is only one kernel listed here, so there isn't much choice). This file has to be named menu.lst (after the dot it is an "ell", not a "one").

# Boot automatically after 30 seconds.
timeout 30

# Comment lines begin with '#'
#
# "(hd0,1)" means "/dev/hda2".
# "(hd0,1)" refers to disk 0 (the first disk), and the SECOND
# partition (partition 1), which is /dev/hda2 (NOT /dev/hda1):
#       - GRUB numbers partitions and disks starting at 0, not 1.
#
#       - The "root=/dev/hda2" section is also referring to the
#         second partition, but the kernel (not GRUB) starts
#         numbering partitions at 1, not 0.
#
title Linux
    root (hd0,1)
    kernel /boot/summer-usb ro root=/dev/hda2 hdc=ide-scsi
Note: In the GRUB menu.lst file the partition numbers in the "root (hd0, X)" line start at 0 (not 1), while the partition numbers in the "root=/dev/hdaY" kernel argumentline start at 1 (not 0).

Here is another GRUB configuration file, this time with 2 kernels to choose from:

# By default, boot the first entry (Red Hat rather than Debian).
default=0
#Start booting automatically after waiting 10 seconds.
timeout=10

splashimage=(hd0,1)/boot/grub/splash.xpm.gz

title Red Hat Linux 9 with kernel (2.4.20-8)
    root (hd0,0)
    kernel /boot/vmlinuz-2.4.20-8 ro root=LABEL=/
    initrd-2.4.20-8.img

# Note you can tell GRUB where to find the "/boot/summer-debian"
# kernel without a separate "root (hd0,4)" line.  Instead,
# the device is specified to GRUB on the kernel line.
#
# Also, note that "(hd0,4)" refers to "/dev/hda5".  GRUB
# starts numbering partitions at 0, which means partition 4
# "(..,4") is the 5th partition, which is /dev/hda5, not /dev/hda4.
title Debian Linux
        kernel (hd0,4)/boot/summer-debian ro root=/dev/hda5
And another example, this time with a Windows 2000 partition:
default=0
timeout=30
# Fallback to the second entry, if the first one fails.
fallback 1

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

title Debian Linux
        root (hd0,4)
        kernel /boot/vmlinuz-2.2.20 ro root=/dev/hda5

#   Device Boot    Start       End    Blocks   Id  System
#/dev/hda1   *         1       305    307408+   6  FAT16
#/dev/hda2           306       789    487872    5  Extended
#/dev/hda5==(hd0,4)  306       741    439456+  83  Linux
#/dev/hda6           742       789     48352+  82  Linux swap

And another example, this time with many kernels to choose from:

# Note that you do not have to rerun GRUB after
# making changes to this file
default=0
timeout=10
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

# This is for disk 0, partition 0 ["root (hd0,0)"],
# which is /dev/hda1
title Red Hat Linux (2.4.20-8)
        root (hd0,0)
        kernel /boot/vmlinuz-2.4.20-8 ro root=/dev/hda1
        initrd /boot/initrd-2.4.20-8.img

# This is for disk 0, partition 1 ["root (hd0,1)"],
# which is /dev/hda2
title Mandrake Linux
        root (hd0,1)
        kernel /boot/vmlinuz root=/dev/hda2

# This is for disk 0, partition 2 ["root (hd0,2)"],
# which is /dev/hda3
title SuSE Linux
        root (hd0,2)
        kernel /boot/vmlinuz ro root=/dev/hda3

# This is for disk 0, partition 3 ["root (hd0,3)"],
# which is /dev/hda4
title Debian Linux
        root (hd0,3)
        kernel /boot/vmlinuz-2.4.20 ro root=/dev/hda4

# This is for disk 0, partition 4 ["root (hd0,4)"],
# which is /dev/hda5
title Turbo Linux
        root (hd0,4)
        kernel /boot/vmlinuz-2.4.20 ro root=/dev/hda5


Where to get more information

Linux Quick Reference Home
Linux Migration Home