Configuring GRUB





Last Updated on 08/12/2010 by dboth

Until recently, about Fedora 8 or 9, GRUB was somewhat verbose during boot and would allow a user to directly interact during the boot process to choose other kernels to boot or to modify the kernel parameters. More recent versions of Fedora skip past the GRUB menu and provide no opportunity for editing kernel parameters or booting alternate kernels. This seems to be in keeping with the movement to make all distributions more friendly to users with little or no experience with a real operating system by hiding much of the complexity and normal messages and options that system administrators like to see.

The boot behavior can be configured as you will see below. Any configuration changes made to grub.conf are permanent and will persist through reboots.

grub.conf

The GRUB configuration file is /boot/grub/grub.conf and there is a link to it in /etc/. This file can be edited directly to change the GRUB configuration. The grub.conf file below is taken from one of my workstations.


# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_david1-lv_root
#          initrd /initrd-version.img
#boot=/dev/sda
default=1
timeout=9
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.29.5-191.fc11.i686.PAE)
   root (hd0,0)
   kernel /vmlinuz-2.6.29.5-191.fc11.i686.PAE ro root=/dev/mapper/vg_david1-lv_root quiet
   initrd /initrd-2.6.29.5-191.fc11.i686.PAE.img
title Fedora (2.6.29.5-191.fc11.i586)
   root (hd0,0)
   kernel /vmlinuz-2.6.29.5-191.fc11.i586 ro root=/dev/mapper/vg_david1-lv_root quiet
   initrd /initrd-2.6.29.5-191.fc11.i586.img
title Fedora (2.6.29.4-167.fc11.i586)
   root (hd0,0)
   kernel /vmlinuz-2.6.29.4-167.fc11.i586 ro root=/dev/mapper/vg_david1-lv_root quiet
   initrd /initrd-2.6.29.4-167.fc11.i586.img
title Fedora (2.6.29.4-167.fc11.i686.PAE)
   root (hd0,0)
   kernel /vmlinuz-2.6.29.4-167.fc11.i686.PAE ro root=/dev/mapper/vg_david1-lv_root quiet
   initrd /initrd-2.6.29.4-167.fc11.i686.PAE.img

General Options

The first section provides general configuration options. The “default=1” option specifies which of the kernels to load. Note that the first kernel stanza, the one at the top, is numbered “0” so “default=1” specifies the second kernel stanza as the one to load. “timeout=9” is the amount of time to delay in order to allow a user to press a key to select a different kernel or to edit kernel parameters. The default timeout is 5 but I usually change it to 9 because todays displays can blank out as the resolution changes during boot and it takes a couple seconds to resync. This may only leave a second or two to respond in which to press a key.

The entry “splashimage=(hd0,0)/grub/splash.xpm.gz” specifies the name of the image to use for the GRUB splash screen. You can change this to specify a custom splash screen such as a company logo. The “hd0,0” portion of this line specifies the hard drive on which the image is located. This notation is required at this time during the boot process because the kernel has not yet loaded and so no drive identifiers such as /dev/hda have been assigned. This notation is also used in the kernel stanzas to identify the boot partition for the same reason.

The “hiddenmenu” line specifies that the splash screen is not displayed and the user therefore has no option available to press a key and edit the kernel boot parameters or to select a different kernel to boot. If you want those options available you should comment this line out or remove it.

Kernel Stanzas

Notice that there are four kernel stanzas. Each one is different in some way. I have two PAE (Physical Address Extenstion) kernels which allow addressing more than 4GB of RAM and two standard kernels which do not. Fedora 11 loaded the PAE kernels by default, but I am not yet sure why as I only have 2GB of RAM in this particular computer. In addition I use the standard kernels as my default because the virtualization software, VirtualBox, does not seem to recognize the PAE kernels. I could probably download the appropriate kernel header and development files and recompile the VirtualBox kernel module but I have not bothered because, as I mentioned already, I have only 2GB of RAM so there is no need for the PAE kernel.

There are two of each of the PAE and standard kernels because there have been updates to the original kernel.

Each kernel stanza has four lines. The first line is the title line. It specifies the text a user sees on the GRUB menu. This can be any text you want and it has no effect on the boot process itself.

The second line tells GRUB the hard drive on which to find the kernel and other boot files. The “hd0,0” portion of this line specifies the hard drive on which the image is located. This notation is required at this time during the boot process because the kernel has not yet loaded and so no drive identifiers such as /dev/hda have been assigned.

The “kernel” line specifies the kernel name and specific version along with the location of the “/” root partition. It also may include one or more kernel boot parameters and other parameters such as those that might be passed to init.

In the illustration above the only parameter on the kernel line is “quiet” which means that the kernel does not spew large amounts of startup messages to the screen. Those messages are the ones that are stored in /var/log/dmesg so you can check there for them after boot. This keeps the screen clean and the system takes less time to boot because it does not have to print large numbers of messages to a possibly very slow display. Even today’s fast displays slow down the computer significantly during boot and other times, too, as any I/O is slow compared to processor speed.

The last line is the “initrd” line which defines the location and name of the initial RAM disk file. The initrd file contains drivers and libraries required during boot but that are not otherwise available because the file systems have not yet been mounted.





Leave a Reply