LILO is the most commonly used boot loader for Linux on Intel-based/compatible systems. A boot loader is a program that loads the operating system into the computer's memory from its hard disk when the computer is first started up. When a computer is booted, the first thing it does is to look at a fixed sector of its hard disk; the "master boot record" (or MBR). The program it finds there (in this case LILO) is responsible for loading and starting whatever operating system the computer is going to run. LILO, which stands for LInux LOader, is a very efficient boot loader, and it may be used to start other operating systems in addition to Linux.
LILO is the most commonly used boot loader for Linux on Intel-based/compatible systems. A boot loader is a program that loads the operating system into the computer’s memory from its hard disk when the computer is first started up. When a computer is booted, the first thing it does is to look at a fixed sector of its hard disk; the “master boot record” (or MBR). The program it finds there (in this case LILO) is responsible for loading and starting whatever operating system the computer is going to run. LILO, which stands for LInux LOader, is a very efficient boot loader, and it may be used to start other operating systems in addition to Linux.
The first visual indication of LILO’s functioning is its familiar boot prompt, LILO: (which is itself a four-character diagnostic indicating the progress of the boot loading process). Pressing the Tab key in response to this prompt brings up a list of boot choices. You can select one of them by entering its name at the prompt, and you can specify boot-time options by appending them to that command line. For example, entering linux single will boot the default kernel in single-user mode on most systems.
Listing One: A Simple lilo.conf File
These boot choices, as well as many other aspects of LILO’s functioning, are specified in its configuration file, traditionally /etc/lilo.conf. Listing One shows a very simple version of this file, which you might find on a system where Linux has just been installed.
The upper section of Listing One contains general settings that apply to every kernel and operating system that LILO may boot. The first three lines in this section set the boot, map, and install variables, which specify where LILO is to be installed (in this case, in the master boot record of the first IDE disk), the location of the map file, and location of the boot sector image, respectively. The latter two items are set to their defaults and should not be modified unless you have a pretty deep understanding of LILO. The final two lines in this section indicate that LILO should present a prompt to the user before loading any operating system or kernel (the prompt keyword) and that it should automatically load the default operating system if no response is given within the first five seconds (the timeout keyword).
After the global section, the LILO configuration file contains one or more sections defining the operating systems and kernels that it can load. In our example, only one item is defined. The image keyword marks the beginning of each item, and its value specifies the disk location of the kernel executable image, interpreted as a directory on the disk partition specified in the root keyword (as specified in the third line in this section). The label keyword specifies a character string associated with the entry that may be entered at the LILO prompt. The final keyword indicates that the specified root filesystem should be mounted read-only.
LILO’s capabilities go beyond what is illustrated in the sample configuration file. For example, it is quite common for multiple image sections to exist in the file. In addition, a variety of other general options and image-specific options may be set. We will see examples of many of them in the remainder of this column.
The LILO configuration file can be edited manually with any text editor. In addition, the linuxconf facility provides a graphical interface for configuring LILO. Two caveats apply to using these linuxconf features, however. First, not all LILO-related keywords can be accessed through the interface, and second, sometimes the configuration files that the utility emits contain syntax errors that keep them from installing properly. The LILO facility is complex enough that it is always a good idea to inspect any automatically generated configuration file carefully before installing it.
|Figure One: Setting general LILO options with linuxconf.|
LILO configuration may be performed by selecting linuxconf’s “Config -> boot mode ->Lilo”menu path; the resulting submenu is illustrated in the left side of Figure One (indicated by the yellow highlighting).
The right side of Figure One is a composite, showing both panels, which are made available by selecting the “LILO defaults” menu item. The upper part shows the “Base options” panel, which contains fields for the most commonly used general options. The check box at the top of this panel (“LILO is used to boot the system”) indicates whether LILO is active or not; it is useful for disabling LILO features within linuxconf when a different boot loader is used on the system. The remaining fields on the panel each correspond to a different LILO configuration-file keyword (indicated in red in the illustration).
For example, the field labeled “Boot delay in seconds” corresponds to the delay keyword, which specifies the amount of time to wait before automatically booting the operating system; accordingly, the keyword assumes that only one choice is defined within the LILO configuration file, and that user prompting is disabled.
The sample configuration file showed examples of the install, prompt, and timeout keywords. These keywords may also be set from the final three fields on this panel. Note that the units for timeout are in seconds within linuxconf, while they are in tenths of seconds within the actual configuration file. You can use the final field in this panel to specify the location of a text file for LILO to display before issuing its prompt (via the message keyword); conventionally, this file is stored in the /boot directory.
The panel also allows you to specify some nonstandard behavior for LILO, which is necessary for some unusual hardware configurations. Checking the “Compact” box includes the compact keyword within the configuration file; it says to attempt to merge read requests for adjacent sectors while loading, a process that can provide significant performance improvement when booting from floppy disk but makes little difference for hard disks. Similarly, the “Linear” box includes the linear keyword, which changes LILO’s disk-addressing scheme from sector/head/cylinder to the linear sector number. This change is needed for a few large IDE disks and some PCI SCSI controllers. It is incompatible with floppy disks.
The lower half of the right side of Figure One illustrates the “Extra options” panel. Once again, the configuration file keywords associated with each field are indicated in red in the illustration. Some of them were introduced in the sample configuration file. For example, the root keyword was present in the image section of the example file. However, as its presence on this panel implies, the keyword may be set on either a global or a per-image level (many other keywords function similarly).
The vga and append keywords are actually Linux kernel keywords and are passed along to the kernel by LILO. The append keyword may be used to pass any desired keyword to the kernel; in this case, I specify settings for a Trantor T128 SCSI adapter. Note that the specified string is enclosed in quotation marks (linuxconf will not add them for you).
The final two items in this panel specify a password protecting access to the system at boot time. The password keyword specifies the desired password in cleartext form, and it applies to every item within the file when it appears in the general section (although it may be overridden within the section for a given image). Note that the password is also stored in cleartext within the configuration file, so be sure to set proper protections on the file if you use this keyword (/etc/lilo.conf is often world-readable by default). The “Restricted accessed” check box modifies the effect of the password keyword in that the password will only be required when the image selection made at the LILO prompt is followed by command-line options. As such,despite the box’s label and the name of the associated keyword (restricted), selecting this option actually makes the password protection less restrictive.
|Figure Two: Setting up a LILO Linux configuration.|
You can also use linuxconf to set up individual image sections within the LILO configuration file. For example, sections corresponding to Linux kernels may be set up via the “LILO linux configurations” menu item. The resulting dialogs are illustrated in Figure Two. The list at the top of the right side of the illustration appears first; clicking on an item within it (or clicking the “Add” button) brings up the Linux boot configuration dialog.
Many of the fields in this dialog are familiar from the preceding panels; in this case, however, the associated keywords are placed within the image section and apply only when that kernel is selected for booting. The first three fields in the dialog correspond to the label, image, and root keywords, respectively. In general, options within image sections take precedence over those within the general section of the configuration file.
For example, if you specify the password keyword within both sections, then the password specified within the image section is the one that must be entered in order to boot that kernel. Similarly, if you specify the password within the general section and a different password within one of the items in the configuration file, including the restricted keyword along with it, then when that item is selected, no password will be required unless additional options are specified along with the item label. (In effect, this is the method for overriding the general password requirement for a specific image.)
|Figure Three: Configuration for a new kernel.|
When you have built a new kernel, you can use linuxconf to set up the LILO configuration file section for it and also to install it into its permanent location. The resulting dialog is a combination of the standard Linux boot configuration dialog and a few fields relating to the location and target directory for the new kernel. It is illustrated in Figure Three.
The “Kernel image file” field specifies the location of the recently built kernel, and the “Where to copy the kernel file” field specifies its installed location. Here, I copy a bzImage file in a standard location to the /boot directory, giving it the name kernel-new. I specify new as the label for the image section and indicate that it will be a new section within the LILO configuration file by choosing the “selectable setup” radio button. Note that the latter is good practice in general: Always add new entries to the configuration file rather than modifying existing, working ones. This leaves you a back-out route in case things go awry.
I noted that LILO can be used to boot other operating systems in addition to Linux. The linuxconf facility for setting up these configurations is reached via the “LILO other OS configurations” menu item. The resulting dialogs allow you to specify only the label and disk partition associated with the foreign operating system. Listing Two is an example of a more complex LILO configuration file, containing sections for three Linux kernels and one for Windows NT. The general section contains keywords discussed earlier, including a message file, a prompt timeout of 15 seconds, and a default password.
Listing Two: A Complex LILO Configuration File
boot = /dev/hda
timeout = 150
message = /boot/lilo.text
password = xxxxxxxx
append = “t128=0xc8000,10″
image = /boot/vmlinux-2.2.5-15
label = linux
root = /dev/hda5
image = /boot/vmlinux-test
label = test
root = /dev/hda5
password = yyyyyyyy
image = /boot/bzImage
label = new
vga = normal
root = /dev/hda5
other = /dev/hda1
label = nt
If no response is entered at the prompt within 15 seconds, then the default image — the first one defined in the configuration file — is started automatically. However, when the password keyword is present in the general section, LILO will continuously cycle between the main and password prompts as each one times out in turn, effectively ignoring any setting in the timeout keyword. Hence, including both a timeout and a password within the general section, as this example file does, is pointless.
The final section illustrates how to set up LILO for a foreign operating system. The other keyword replaces image, and its value specifies the disk partition where the desired operating system is installed. The table keyword indicates where the partition table for the corresponding hard disk is located; its value is virtually always set to the special file corresponding to that disk as a whole (i.e., without any partition number).
Once LILO’s configuration file is set up, it must be activated; in other words, it must be installed within the master boot record of the appropriate disk, or, in some circumstances, within the partition boot record of the appropriate disk partition. This may be accomplished within linuxconf by clicking “Yes” when the utility asks you if you want to activate the new configuration.
Alternatively, it can be accomplished manually by running the /sbin/lilo command. Note that the LILO configuration must be reinstalled whenever you recompile the kernel, even if the result has the same name as the previous kernel, or change any aspect of LILO’s configuration. When in doubt, you can always rerun /sbin/lilo, since doing so multiple times is perfectly safe.
In this column, I covered only the most frequently needed LILO features. However, LILO has a variety of other capabilities suited to addressing many unusual situations. For additional information about LILO, consult the following documentation:
* LILO User’s guide: generally located at /usr/doc/lilo*/doc in most Linux distributions (where the lilo* component includes a version number).
* BootPrompt-HOWTO: generally located within the /usr/doc/HOWTO subdirectory in most Linux distributions.
* The LILO Mini-HOWTO: http://metalab.unc.edu/mdw/HOWTO/mini/LILO.html
AEleen Frisch is the author of O’Reilly & Associates’ Essential System Administration. She can be reached at firstname.lastname@example.org.