21.1. Introduction to Boot Loaders

When a Linux system running on PC hardware is started, the first code to be run is the BIOS (Basic Input Output System) which is loaded from ROM. After it has finished testing the system's memory and discovering what hardware is installed, it attempts to pass control to an operating system boot loader to continue the boot process. The boot loader is a tiny program that may prompt the user to choose which OS to run, and then loads the rest of the operating system kernel from a hard drive, floppy disk, or some other source.

On a normal system, the boot loader is loaded by the BIOS from the first block on the primary hard drive, called the master boot record or MBR. The BIOS, however, may (depending on its configuration) check the floppy drive or CD-ROM for a boot loader first, so the system can be booted off a removable disk. This is usually only done when installing a new operating system—for normal everyday use, almost every system boots from hard disk.

There are several boot loaders available for Linux, but the two most common (and the two which will be covered in this chapter) are LILO and GRUB. Both work only on x86-compatible PC hardware, so if you are running Linux on an Apple, SPARC, or Alpha system, this chapter will not be much use to you. Each non-PC hardware platform has its own specialized Linux boot loader designed to deal with the particular quirks and requirements of the platform.

Other operating systems (such as Windows, FreeBSD, and Solaris) have their own boot loaders, which do basically the same thing as LILO or GRUB, but are designed to load the kernel of a different OS instead. Webmin does not support the configuration of any non-Linux boot loader, so if you are running a different version of UNIX, this chapter can be skipped.

On a Linux system, the boot loader's primary responsibility is the loading of the kernel. Once the kernel has been loaded into memory and control has been transferred to it, the boot loader's job is done. The kernel then mounts the root filesystem, initializes drivers, and finally runs the init program to continue the boot process as explained in Chapter 9.

The boot loader can also start the process of loading a totally different OS on systems that have more than one installed. It does this by loading the other operating system's boot loader from the first block of a partition or other hard disk, and then transferring control to it. The other OS then loads exactly as it would if its boot loader were run directly by the BIOS. Being able to decide which operating system to load at boot time makes it practical to have two or more installed on the same system, such as Windows and Linux.

Both LILO and GRUB can be configured to display a menu of boot options when they are loaded, allowing the user to select which particular kernel to load or another operating system to load. Being able to choose from several different kernels can be particularly useful when you have installed a new one and want to have the option of booting into both the new and the old. It is even possible to have several boot options that all load the same kernel version but with different command-line options.

All Linux distributions will give you the option of automatically setting up a boot loader at installation time. You can usually choose to boot other installed operating systems as well—for example, if you are adding Linux to a system with Windows already installed on a different partition. If this default configuration is working for you, be very careful when changing the LILO or GRUB configuration manually or through Webmin. A single mistake may render your system unbootable, and necessitate the use of a rescue disk to recover.

LILO's configuration is stored in the file /etc/lilo.conf. The boot loader itself, however, does not actually read this file—instead, it reads from a separate map file that is built from lilo.conf whenever the lilo command is run. This map file contains the actual on-disk block locations of the kernel files, which allows LILO to load a kernel without having to understand the format of the filesystem on which it is mounted. Any time lilo.conf is changed or a kernel is recompiled or installed, the lilo command must be rerun to update the map file so the boot loader knows where to look on disk.

One major limitation of LILO is that on systems with older BIOSs, it can only boot kernels that lie within the first 8 GB of a hard disk. With drives over 100 GB in size becoming common, this can be a serious problem unless the disk is partitioned properly. Typically, the /boot directory in which kernels are stored is mounted from a separate partition that is located at the start of the disk, and the root directory is mounted from a partition that takes up the rest.

GRUB usually uses the configuration file /boot/grub/menu.lst, but unlike LILO it does understand the format of ext2, ext3, and vfat filesystems and can read the menu.lst and kernel files without the need for a block map. For this reason, and because GRUB can load a kernel stored anywhere on the hard disk, it is usually considered to be a superior boot loader and is slowly overtaking LILO on modern Linux distributions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.80.236