Created Wednesday 1/8/2007
This document discuses configuration of GRUB, the default boot loader installed with Fedora Core linux. A bootloader is estential for managing multiple operating systems. It is also useful for selecting a particular version of an operating system. GRUB is menu driven with the available operating systems defined in the grub.conf(1) file in the /etc filesystem.
GRUB is the only boot loader that can live both on a DOS file system and on a different type of file system (ext3, minix, etc). Other bootloaders like LILO cannot live in a DOS file system, and SYSLINUX can only live in a DOS file system.
The grub bootloader is a graphical boot loader that presents the available operating systems to the user in a menu. The user may choose an operating system to boot by using the arrow keys to make a selection, which can be booted by pressing the "enter" key. See grub options #1A below for grub configuration and #1B for operating system entries.
The grub(1) reads it's configuration file during boot, so that changes made to /etc/grub.conf take effect on the next invocation of grub(1). There is no need to run any command to render the changes active, unlike lilo(1), which requires a privileged execution of "lilo" after editing the configuration file.
There are several options that can be specified that are related to grub itself, rather than to the operating system entries. These are options such as which O/S entry is the default and how long to wait before booting the default o/s. Consider, for example, the following grub options:
default=0 timeout=5 splashimage=(hd0,1)/boot/grub/splash.xpm.gz hiddenmenu
The above grub options tell grub that the first (0th) "title" entry is to be the default, and this default will boot unless there is user interaction in the grub menu within 5 seconds.
The "splashimage" entry tells grub which image to display as the background. Note that the physical disk and partition must be specified as well as the absolute path to the image. The image format must be compressed XPM (.xpm.gz) and must be exactly 640x480 pixels and have a maximum of 14 colors. See for example, the following grub boot splash images (ruslug.rutgers.edu).
The "hiddenmenu" option tells grub not to display the menu by default. Instead, grub presents a message with a countdown (starting at the "timeout" value) telling the user that the default O/S entry will boot unless "enter" is pressed. If the countdown is terminated (by "enter"), then grub shows the menu with the avilable O/S selections.
The file /etc/grub.conf controls which operating systems are available for boot. A entry starts with the "title" keyword, and much like a Makefile, options for the section appear indented after each "title" entry. The "title" itself is free-form text and should indicate the name of the operating system and it's version.
The "root" entry tells the bootloader that this operating system can be found on the physical device hd0, in the second partition.
The "kernel" entry is self explanatory and tells grub where the kernel can be found. The kernel files (map symbols and kernel vmlinuz) are traditionally stored in /boot and must be located on a non-compressed non-lvm partition. Kernel options appear after the location of the kernel
The "initrd" entry is similar to the "kernel" entry and tells grub the location of the kernel image. Again, initrd images traditionally appear in the /boot partition.
The following example illustrates an grub.conf entry:
title FC6 2.6.20-1.2933
root (hd0,1)
kernel /boot/vmlinuz-2.6.20-1.2933.fc6 ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.20-1.2933.fc6.img
title Windows XP x64
rootnoverify (hd0,0)
chainloader +1
The previous example shows two different operating systems are configured for the bootloader. The first is a Fedora Core linux (kernel 2.6.20-1.2933), found on the hd0 (the first hard disk) in the 2nd partition (partition number 1). The second operating systems is windows xp (64-bit) and is also found on the first hard disk (hd0) but is located in partition 0 (the first partition).
▨ Todo: This section is a real mess. Needs reworking
Sometimes it might be necessary to add kernel options to an O/S entry presented in the grub(1) menu. This is especially relevant to linux entries where the user may want to boot a different runlevel other than the configured default. The following steps outline this process, which is temporary, in the sense that the changes are not commited to /etc/grub.conf and are active only for the instance of the running boot loader
Step 1: Choose the grub O/S entry from the grub menu (e.g., arrow key to "title" entry to boot)
Step 2: Press "e" for edit. This will open a grub sub-menu on the selected O/S entry
Step 3: The sub-menu presents the options specified in the "title" section. Using #1B examples, the "title" entry "FC6 2.6.20-1.2933" has 3 options (which appear in a menu): i. root (hd0,1) ii. kernel /boot/vmlinuz-2.6.20-1.2933.fc6 ro root=LABEL=/1 rhgb quiet iii. initrd /boot/initrd-2.6.20-1.2933.fc6.img
Step 4: Use the arrow keys to select a relevant entry. For example, booting to runlevel 3, requires that the kernel options be changed. To do this, modify the "kernel" entry, by pressing down arrow to the 2 menu option (shown in step 2)
Step 5: After selecting the "kernel" options menu item, press "e" for edit. This will make the kernel options line editable.
Step 6: Pressing "e" on the "kernel" options in step 3 above makes the kernel options line editable. To boot runlevel 3, we want to add this runlevel number to the end of the line. Pressing "space" moves to the end of the line, where we can now type the number "3" (i.e., the runlevel), so that the kernel options line now reads:
grub> kernel /boot/vmlinuz-2.6.20-1.2933.fc6 ro root=LABEL=/1 rhgb quiet 3
Step 7: Press "enter" to stop editing, which will move back to the sub-menu shown in step 3.
Step 8: Press "b" to boot with the modified kernel options
Any changes made from the grub menu are not permenant. These changes are in effect only for the duration of that particular grub invocation. To make permenant changes, be sure to edit the grub configuration file, which is /etc/grub.conf
Some operating system installations remove the bootloader. This can be particularly annoying and occurs with earlier versions of windows. Clearly, to re-instate the bootloader we'd need to have linux booted, so this particular discussion assumes that the linux installation with the appropriate grub configuration is booted.
Grub provides grub-install(1) as the means of installing grub as the bootloader in the master boot record. Invocation is basic and requires that the device location of where the bootloader should be installed. The argument can be either a device file (like /dev/hda) or a partition specified in grub notation. For example, to install grub into the MBR if the first ide disk:
bash # grub-install /dev/hda # NOTE ASSUMES images are in /
The alternate device "/dev/hd0" can also be specified for GNU. Further, if the disk is the first BIOS drive, then '(hd0)' can be used as well as can 'hd0', e.g.,:
bash # grub-install '(hd0)' or even grub-install hd0
The above examples assume that GRUB should use images under the root directory. If the boot images are located in a directory other than the root directory, then the --root-directory option must be given. The :Fedora standard for installing grub is to specifying images in the /boot directory. To install grub into the MB of the first IDE disk, loading images from /boot:
bash # grub-install --root-directory=/boot /dev/hda
The grub shell provides the user with the opportunity to edit boot options before loading a boot image. In a typical configuration, grub starts up in the graphical environment and presents the user with a simple menu that lists the bootable images defined in grub.conf. The user may choose one of these bootable images and press enter, which will then pass the kernel parameters and boot options to the boot loader for the selected item.
The user may choose to perform a non-persistent edit of the boot options prior to booting an image. This is useful if booting to a specific runlevel is required, as described in #2, above. In addition, the grub shell provides rudimentary command to specify the image to load, options for rebooting and so on.
▨ Todo: This section needs work. Could be merged with point #2
Other bootloaders:
See also:
Stuart Moorfoot \copy 2 August 2007 foo@bund.com.au