III.  Boot managers


III.3  Linux Loader

Basics

Linux Loader, or shortly LILO, is a versatile Linux boot manager. It does not depend on a specific file system, can boot Linux kernel images from floppy and hard disks. On a machine with multiple operating systems installed, LILO can be used to boot other than Linux operating systems. LILO can be installed into VBS, or alternatively into MBR of any hard disk present on the system. When LILO is installed into MBR of the boot disk, it takes control over the boot process of the machine. In both cases, however, LILO allows to select the partition to boot off the operating system. It depends on the user's preferences which boot manager is a default one. If e.g. Solaris and Linux are configured adequately on a machine, endless cycling through Solaris and Linux boot managers is possible.

Linux device naming convention

Before we enter into the details of LILO configuration, some knowledge on how media devices are named in Linux is worth mentioning. All devices in Linux, as in Unix system, are accessed by (device) files. Floppy disks are addressed by /dev/fd0 and /dev/fd1, which correspond to DOS drive A: nad B:, respectively. IDE/ATA hard disk drives are addressed as follows:

Note that drive lettering is the same as in BIOS boot sequence setting. SCSI hard disk drives are addressed by /dev/sda, /dev/sdb and so on. Letter 'a' means the first device in the SCSI chain, 'b' the second one and so on.

Primary partitions on, both IDE/ATA and SCSI, hard disk drives are numbered from 1 to 4, so that e.g. the second primary partition on a secondary master IDE/ATA drive is addressed by /dev/hdc2. Extended partitions have no their addresses, as they are useless. Logical volumes on extended partitions are numbered from 5 up, so that e.g. the third logical volume on the extended partition on a primary slave IDE/ATA drive is addressed by /dev/hdb7.

Lilo configuration

LILO is fully customizable. Its configuration file is /etc/lilo.conf. LILO is initially preconfigured during the Linux installation process. With these, default settings LILO knows nothing about other operating systems installed on a machine, and can boot only Linux. In this situation it behaves simply as DOS or Windows 9x, which can't boot anything but themselves.

The syntax of the /etc/lilo.conf file is simplified. It contains variables that can have values assigned to, and switches. Some variables implicitly determine sections. We discuss only those variables and switches which are necessary to configure LILO to boot Linux and other operating systems. For more details refer to LILO documentation distributed along Linux, [Veselosky] or [Skoric].

An example /etc/lilo.conf may look as follows:

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

This example file is taken from the system with one IDE/ATA hard disk drive with NT installed on the first primary partition, Solaris on the second one and Linux on the third one. LILO is installed into MBR and is used as the default boot manager. Used variables and switches have the following meaning.

boot
Determines where LILO will be installed. Any device address associated with a fixed media or any partition address is a valid value. Usually it points to either MBR of the boot drive, or VBS of Linux boot partition. E.g. /dev/hda tells LILO to install into MBR of a primary master IDE/ATA hard disk drive. /dev/hdb3 means third primary partition on a primary slave drive, and /dev/sda5 means the first logical volume on the extended partition on the first SCSI drive.
map
Variable used internally by LILO.
install
Specifies the file containing Volume Boot Code.
compact
Switch that makes LILO read the hard drive faster.
prompt
This is a switch that tells LILO to prompt a user at boot time to choose an operating system or enter parameters for the Linux kernel.
timeout
Specifies how long to wait at the prompt before booting the default operating system. Measured in tenths of a second. 50 means 5 seconds; 0 or not present variable at all causes LILO to wait endlessly or boot immediately as prompt switch is specified or not.
image
Specifies the name of a Linux kernel for LILO to boot, e.g. /boot/vmlinuz-2.0.39. This variable 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
The name that is used to identify this image at the LILO boot prompt. Typing this identifier will select this image. Usually set to linux.
root
Specifies the volume where the root (/) file system resides, in other words, the boot volume of Linux. Note that it may be either a primary partition or a logical volume. This file system will be mount at the boot time. If LILO is installed into VBS, this value should be equal to the value of boot.
read-only
This switch is usually present and causes the Linux kernel to initially mount the root file system as read-only and remount as read-write later.
other
This variable is optional and has similar meaning for other than Linux operating system as image has for Linux. It begins a section for such a system. Its value points to the boot partition of that operating system. LILO will simply load and execute the VBS of this partition at boot time.
label
Same as the label above. Specifies an identifier to refer to the operating system at LILO boot prompt.

Every time /etc/lilo.conf is modified, we have to apply changes to take effect. To do that run as root :


/sbin/lilo


Successful configuration of Linux and other operating systems specified in /etc/lilo.conf is reported by displaying "Added label". An asterisk indicates the default operating system to boot.

Using LILO

Though LILO realizes relatively advanced tasks, its usage is simplified. It is not menu driven, instead a prompt "LILO:" for user input is displayed. LILO then waits the amount of time specified in /etc/lilo.conf and if there is no user input, it loads the default operating system. Operating systems are selected by their labels specified in /etc/lilo.conf. To list all available identifiers TAB key may be pressed.

Additional parameters to Linux kernel may be given after the Linux identifier.

Recovering LILO

When Linux is installed prior other operating system, LILO that was written into MBR may no longer be available. This happens when e.g. DOS, Windows, including NT and W2K, or Solaris are installed after Linux. LILO might be wiped out not only during other operating system installation, but also by certain disk utilities or anti-virus software. In case we want LILO to manage the boot process from its very beginning, it needs to be restored. This is done the same way changes to LILO configuration are applied. So, Linux must be booted some other way, e.g. by Loadlin or Linux boot floppy, and /sbin/lilo must be run by root.

Keep in mind that this procedure restores Master Boot Code only, not Master Partition Table. That is in case of disaster, when entire MBR is lost, restoring LILO as described above will not fix the problem. In general this means that the data on the hard disk drive is lost. To avoid such problems MBR should be backed up after every modification.

Removing LILO

Discussing LILO and its configuration we should mention that it is possible to remove LILO from MBR safely. Before LILO is installed the original Master Boot Code is saved for future restoration. This feature may be used when one decides to uninstall Linux. It is done by running /sbin/lilo with option -u. If Linux can not be loaded we may also try DOS fdisk utility or Ranish PM to rebuild MBR.