Previous Section  < Day Day Up >  Next Section

Recipe 12.9. Creating the GRUB Boot Menu

12.9.1 Problem

As fun as it is to discover root devices and kernels from the GRUB command line, you would like to preserve your boot parameters in a configuration file and have a nice boot menu to use at startup. In this menu you will configure your chosen defaults, and have a menu of all of your installed operating systems to choose from.

12.9.2 Solution

Add boot entries to GRUB's configuration file, /boot/grub/menu.lst. (Red Hat uses grub.conf and creates a soft link named menu.lst.)

GRUB calls the different boot entries stanzas. Here is a basic configuration:

title         Fedora 1 core

root          (hd0,0)

kernel        /boot/vmlinuz-2.4.22-1 root=/dev/hda1 ro

initrd        /boot/initrd-2.4.22-1.img

The title can be anything at all, and you must have one—it tells GRUB where each stanza starts, and it appears in the boot menu. The other two lines are the same values we used on the GRUB command line. It is not necessary to use the boot command in menu.lst.

You can list as many operating systems as you want; each one requires a stanza like this one. Make sure the kernel line points to the right partition and kernel executable. It's common to have several bootable kernels in the same root partition. And it is common (even good) for all the boot configurations to use the same boot partition.

Not all Linux distributions require a ramdisk, which is loaded by the initrd image. If /boot/initrd-* exists, you must use it.

12.9.3 Discussion

Remember that the root device, indicated by:

root          (hd0,0)

is the location of the /boot directory, and hd0,0 is GRUB's own numbering system. On the kernel line:

kernel        /boot/vmlinuz-2.4.22-1 root=/dev/hda2 ro

root is the root filesystem, using the kernel dev name.

12.9.4 See Also

    Previous Section  < Day Day Up >  Next Section