Boot Loader


Boot Loader

A boot loader is a very small program that is used in the (page ) process, which brings a computer from off or reset to a fully functional state. The boot loader frequently resides on the starting sectors of a hard disk called the MBR (Master Boot Record).

The (page ), stored in an (page ) on the system's motherboard, gains control of a system when you turn on or reset the computer. After testing the hardware, the BIOS transfers control to the MBR, which usually passes control to the partition boot record. This transfer of control starts the boot loader, which is responsible for locating the operating system kernel (kept in the / or /boot directory), loading that kernel into memory, and starting it running. Refer to "" on page for more information on what happens from this point forward.

You can place the /boot directory on a very small filesystem that is located near the beginning of the hard drive, where the BIOS can access it. With this setup, the root (/) filesystem can be anywhere on any hard drive that Linux can access and that perhaps the BIOS cannot.

grub: The Linux Loader

The name grub (see the grub info page and ) stands for Grand Unified Boot Loader. A product of the GNU project, the grub loader conforms to the (page ), which allows it to load many free operating systems directly as well as to chain load (page ) proprietary operating systems. The grub loader can recognize various types of filesystems and kernel executable formats, allowing it to load an arbitrary operating system. You must specify the kernel's filename and location (drive and partition) so that grub knows where to find the kernel. You can pass this information to grub via either the command line or the menu interface. When you boot the system, grub displays a menu of choices that is generated by the /boot/grub/grub.conf file (or see its symbolic link, /etc/grub.conf). At this point you can modify the menu, choose which operating system to boot, or do nothing and allow grub to boot the default system. When you install grub at the time you install Linux, the installation program configures grub automatically, so you do not have to.

The /boot/grub/grub.conf file is the default grub configuration file. The grub.conf file in the following example is from a system that had its kernel replaced (there are two versions of vmlinuz and initrd). The system has a separate boot partition so that all kernel and initrd (for systems using loadable modules; see page ) image paths are relative to /boot (see the NOTICE in the file). Without a separate boot partition, the boot files reside in the root partition (/) so that kernel and initrd paths are relative to /.

The file starts with comments that Anaconda, the graphical installer, puts there, followed by four assignments. The default is the section number of the default boot specification. This numbering starts with 0. The example includes two boot specifications: The first, numbered 0, is for the 2.6.15-1.1881_FC5 kernel; the second, numbered 1, is for the 2.6.15-1.1878_FC5 kernel. The timeout is the number of seconds that grub waits after it has prompted you for a boot specification before it boots the system with the default boot specification. The splashimage is the grub menu interface background that you see when you boot the system. When you specify hiddenmenu, grub boots the default entry and does not display the menu interface unless you press ESCAPE while the system is booting.

$ cat /etc/grub.conf
# 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/hda2
#          initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Centos Linux (2.6.15-1.1881_FC5)
        root (hd0,0)
        kernel /vmlinuz-2.6.15-1.1881_FC5 ro root=LABEL=/1 rhgb quiet
        initrd /initrd-2.6.15-1.1881_FC5.img
title Centos Linux (2.6.15-1.1878_FC5)
        root (hd0,0)
        kernel /vmlinuz-2.6.15-1.1878_FC5 ro root=LABEL=/1 rhgb quiet
        initrd /initrd-2.6.15-1.1878_FC5.img

Following the hiddenmenu assignment in the preceding example are two boot specifications, differentiated by the title lines as explained previously. The three lines following the title line in each specification specify the location of the root (drive 0, partition 0), kernel, and initrd images. In this case, because there is a /boot partition, the pathnames are relative to /boot. For the default boot specification (the first one, numbered 0), the absolute pathname of the kernel is /boot/vmlinuz-2.6.15-1.1881_FC5, which is specified with the options ro root=LABEL=/1 rhgb quiet. These options tell grub that it is to be mounted readonly and that root (/) is mounted on the device labeled /1 in /etc/fstab (page ). The rhgb (Red Hat graphical boot) software generates a graphical display that tells you what is happening as the system boots. The quiet option produces less debugging output so it is easier to tell what is happening. You specify the initrd (initialize RAM disk, page ) image in a manner similar to the kernel. Substitute the local kernel and initrd names and version numbers for the ones in the example. Make sure that when you install a new kernel manually, its title line is different from the others in grub.conf.

LOADLIN: A DOS-Based Linux Loader

The LOADLIN loader, a DOS utility that loads Linux from DOS and some versions of Windows, can load big kernels (bzImage) and RAM disk images (initrd). Refer to , where you can find the LOADLIN Users Guide and other information. See also the Loadlin+Win95/98/ME mini-HOWTO.