Guide to Linux for Beginners

Configuring LILO, the Linux Loader

«  Choosing a Boot Loader   ::  Contents  ::   Linux Installation, Step by Step  »

Configuring LILO, the Linux Loader

What is LILO?

LILO is the LInux LOader, the most popular boot loader for Linux. (For some background on boot loaders, see Choosing a Boot Loader) It is used to load Linux into memory and start the operating system. On a machine with multiple operating systems, LILO can be configured to boot the other systems as well.

Normally LILO is initially configured for you during the Linux installation process. However, you may find that default configuration is not correct, or you wish to customize it. And there may even come a time when you need to remove LILO from your computer. Here are some instructions that should help you on your quest.

The /etc/lilo.conf File

As with many Linux utilities, LILO can be customized with a configuration file in the /etc directory. The lilo.conf file has its own man page which is quite thorough. In fact, it may be a little too thorough for simple configuration. So here’s the lowdown on your basic lilo.conf file.

The sample lilo.conf file shown below is for a typical dual-boot configuration, with Windows installed on the first partition and Linux on the second. You can probably use this as-is, except for the image= line and possibly the root= line, depending on where Linux was installed. Detailed explanation follows.

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
compact
prompt
timeout=50
image=/boot/vmlinuz-2.0.36
    label=linux
    root=/dev/hda2
    read-only
other=/dev/hda1
    label=win

boot=/dev/hda

Tells LILO where to install the bootloader. In this case, it is going into the master boot record of the first hard drive, which means LILO will control the boot process of all operating systems from the start. It could also have been /dev/hda2, the boot sector of the Linux partition. In that case, the DOS bootloader would need to be in the master boot record, and booting Linux would require setting the Linux partition active using fdisk.

map=/boot/map

The map file is automatically generated by LILO and is used internally. Don’t mess with it.

install=/boot/boot.b

Tells LILO what to use as the new boot sector. This file contains the “bootstrap” code that starts your operating system. Don’t mess with it.

compact

Makes LILO read the hard drive faster. Normally you want this, but some older systems may hang. Remove it if yours is one of these.

prompt

Tells LILO to prompt us at boot time to choose an operating system or enter parameters for the Linux kernel. Keep this.

timeout=50

Tells LILO how long to wait at the prompt before booting the default operating system, measured in tenths of a second. The configuration shown waits for 5 seconds. If timeout is 0 or not present, LILO waits forever (if prompt is specified, otherwise boots the default immediately).

image=/boot/vmlinuz-2.0.36

The name of a Linux kernel for LILO to boot. This begins a section, and the lines that follow give specific parameters for this particular kernel. You may have up to sixteen image sections, but one should suffice. The first image listed in the file is the default, unless you specify otherwise.

label=linux

The name that is used to identify this image at the LILO: boot prompt. Typing this name will select this image. When asked to list the available images (by pressing TAB at the LILO: prompt), LILO will display this name in the list.

root=/dev/hda2

Tells LILO where the root (/) file system is (in other words, where Linux lives), so that the Linux kernel can mount it at boot time. Unless you are doing something extremely high-tech, all your images should use the same root= parameter. In my case, Linux is installed in the second primary partition.

read-only

Tells LILO to instruct the Linux kernel to initially mount the root file system as read-only. It will be remounted as read-write later in the boot process. This is the normal method of booting Linux. Don’t change it unless you are sure you know what you are doing.

other=/dev/hda1

Like the image line, this begins a section. other tells LILO to boot an operating system other than Linux. It is given the value of the partition where this other operating system lives. LILO will simply load and execute the boot sector of this partition at boot time.

label=win

Same as the label above, gives you a way to refer to this section.

By copying this basic layout, you should be able to get LILO to boot Windows or any new Linux kernels you build. Before you begin editing, make sure you create a backup copy of the original lilo.conf just in case something goes wrong. And don’t forget to apply your changes!

Applying Changes

Anytime you edit the /etc/lilo.conf, or if you move or rename any of the files used by LILO, including the Linux kernel itself (the vmlinuz file), you must apply your changes before they will take effect. Failing to do so might cause LILO to be unable to boot Linux!

To apply changes, run the following command (you will need to be SuperUser):

/sbin/lilo

You should get a response that looks like this:

Added linux *
Added win

The asterisk * indicates the default boot image. If you see anything other than this, something went wrong. Go back through your lilo.conf and read the man page to see what it was.

Recovering a Lost LILO

If you reinstall DOS or Windows after installing LILO, you may find that the LILO: boot prompt no longer appears. This might also occur if certain disk utilities or anti-virus utilities attempt to “repair” your master boot record. (Some anti-virus programs will see LILO as a virus!)

To fix this, you just need to reinstall LILO. That means you have to boot into Linux some other way, either using Loadlin or a Linux boot floppy. (See Choosing a Boot Loader). At the Linux command prompt just type /sbin/lilo as described under Applying Changes. When you reboot, LILO will be back where it belongs!

Removing LILO

If you have LILO installed as your master boot record and you decide to uninstall Linux or upgrade your hard drive, you will need to remove LILO from the master boot record before you remove it’s files from the hard drive. LILO makes a backup copy of your original master boot record before it installs itself. To remove LILO and return to the original, issue this command:

/sbin/lilo -u

If this fails for some reason, consult the LILO documentation for alternatives.

If the LILO files have already been removed, or you are unable to coax LILO into removing itself, try using the DOS fdisk program to rebuild the master boot record with this command (from a DOS boot floppy):

fdisk /mbr

LILO Usage

At boot time, LILO will present you with a boring prompt:

LILO:

If you do nothing, LILO will wait the amount of time specified in its configuration file and then boot the default operating system image. You can choose an operating system image to boot by typing its label here. If you can’t remember what the labels are, press the TAB key to see a list. The default image is normally labelled “linux”. If your lilo.conf was built by the Linux setup program, you may also have one called “dos” that boots the DOS or Windows partition.

If you need to pass special parameters to the Linux kernel, you can do it by typing them after the image name. For example, if you need to login to Linux in single-user mode to repair a damaged system (or because you forgot the root password), you can type:

linux single

Or if that fails, try:

linux 1

See the BootPrompt How-To for more neat things you can do at the LILO: prompt.

Resources

man pages: lilo, lilo.conf

Documentation: /usr/doc/lilo-*/ contains a very thorough, printable postscript User Guide, with source.

The LILO mini-How-to

The BootPrompt How-To

Table Of Contents

«  Choosing a Boot Loader   ::  Contents  ::   Linux Installation, Step by Step  »