LILO: The Linux Loader

Once you've made the decision to install LILO, you still need to decide how it should be configured. If you want your system to dual boot Linux and Windows/98, you can install LILO on the master boot record (MBR) and set it up to let you select the system to boot. Dual booting Linux and Windows is not quite as straightforward, because Windows has its own loader on the MBR, and it expects to be the one in charge. Therefore, you need to make Linux an option in the NT loader and install LILO in the Linux partition as a secondary boot loader. The result is that the Windows loader transfers control to LILO, which then boots Linux. The same applies to Windows, which uses the NT loader. See "Dual Booting Linux and Windows/2000" later in this chapter for more information.

In addition to booting Linux, LILO can boot other operating systems, such as MS-DOS, Windows/98, or OS/2. During installation, the major Linux distributions provide the opportunity to install LILO; it can also be installed later if necessary. LILO can be installed on the master boot record (MBR) of your hard drive or as a secondary boot loader on the Linux partition. LILO consists of several pieces, including the boot loader itself, a configuration file (/etc/lilo.conf), a map file (/boot/map) containing the location of the kernel, and the lilo command (/sbin/lilo), which reads the configuration file and uses the information to create or update the map file and to install the files LILO needs.

If LILO is installed on the MBR, it replaces the MS-DOS boot loader. If you have problems with your installation or you simply want to uninstall LILO and restore the original boot loader, you can do one of the following:

One thing to remember about LILO is that it has two aspects: the boot loader and the lilo command. The lilo command configures and installs the boot loader and updates it as necessary. The boot loader is the code that executes at system boot time and boots Linux or another operating system.

The LILO Configuration File

The lilo command reads the LILO configuration file, /etc/lilo.conf, to get the information it needs to install LILO. Among other things, it builds a map file containing the locations of all disk sectors needed for booting.

Note that any time you change /etc/lilo.conf or rebuild or move a kernel image, you need to rerun lilo to rebuild the map file and update LILO.

The configuration file starts with a section of global options, described in the next section. Global options are those that apply to every system boot, regardless of what operating system you are booting. Here is an example of a global section (a hash sign, #, begins a comment):

boot = /dev/hda # The boot device is /dev/hda map = /boot/map # Save the map file as /boot/map install = /boot/boot.b # The file to install as the new boot sector prompt # Always display the boot prompt timeout = 30 # Set a 3-second (30 tenths of a second) timeout

Following the global section, there is one section of options for each Linux kernel and for each non-Linux operating system that you want LILO to be able to boot. Each of those sections is referred to as an image section, because each boots a different kernel image (shorthand for a binary file containing a kernel) or another operating system. Each Linux image section begins with an image= line.

image = /boot/vmlinuz # Linux image file label = linux # Label that appears at the boot prompt root = /dev/hda2 # Location of the root filesystem vga = ask # Always prompt the user for VGA mode read-only # Mount read-only to run fsck for a filesystem check

The equivalent section for a non-Linux operating system begins with other= instead of image=. For example:

other = /dev/hda1 # Location of the partition label = dos table = /dev/hda # Location of the partition table

Put LILO configuration options that apply to all images into the global section of /etc/lilo.conf and options that apply to a particular image into the section for that image. If an option is specified in both the global section and an image section, the setting in the image section overrides the global setting for that image.

Here is an example of a complete /etc/lilo.conf file for a system that has the Linux partition on /dev/hda2:

## Global section boot=/dev/hda2 map=/boot/map delay=30 timeout=50 prompt vga=ask ## Image section: For regular Linux image=/boot/vmlinuz label=linux root=/dev/hda2 install=/boot/boot.b map=/boot/map read-only ## Image section: For testing a new Linux kernel image=/testvmlinuz label=testlinux root=/dev/hda2 install=/boot/boot.b map=/boot/map read-only optional # Omit image if not available when map is built ## Image section: For booting DOS other=/dev/hda1 label=dos loader=/boot/chain.b table=/dev/hda # The current partition table ## Image section: For booting Windows other=/dev/hda1 label=win95 loader=/boot/chain.b table=/dev/hda


Global options

In addition to the options listed here, the kernel options append, read-only, read-write, root, and vga (described in "Kernel options" later) also can be set as global options.

Image options

The following options are specified for a particular image.



image = /dev/fd0 range = 1+512 # take 512 sectors, starting with sector 1


Kernel options

The following kernel options can be specified in /etc/lilo.conf as well as on the boot command line:



append = "mem=128M"


The lilo Command

You need to run the lilo command to install the LILO boot loader and to update it whenever the kernel changes or to reflect changes to /etc/lilo.conf.

The path to the lilo command is usually /sbin/lilo. The syntax of the command is:

lilo [options]

Some of the options correspond to /etc/lilo.conf keywords:

Configuration Keyword Command Option
boot=bootdev -b bootdev
compact -c
delay=tsecs -d tsecs
default=label -D label
disktab=file -f file
install=bootsector -i bootsector
lba32 -L
linear -l
map=mapfile -m mapfile
fix-table -P fix
ignore-table -P ignore
backup=file -s file
force-backup=file -S file
verbose=level -v

These options should be put in the configuration file whenever possible; putting them on the lilo command line instead of in /etc/lilo.conf is now deprecated. The next section describes those options that can be given only on the lilo command line; the others are described earlier in this section.

lilo Command Options

The following list describes those lilo command options that are available only on the command line. Multiple options are given separately:

% lilo -q -v