Whenever you hear about Linux, you'll also hear about LILO. LILO is the boot loader used by Linux to load the operating system kernel. Whenever the Linux kernel is changed or moved, LILO must be invoked to rebuild a map of the kernel locations. LILO is
versatile; it can boot Linux kernels from any type of file system, including floppy disk, as well as from other operating systems.
This chapter looks at LILO, the way hard disks are laid out with Linux, the boot process, and the most common boot processes and LILO's interactions with each. This should help you install and use LILO efficiently and effectively.
LILO (which means LInux LOader) is a bit tricky to use if you are not familiar with it and its purpose. You need to install the LILO program, which changes the boot sector of your hard drive to allow you to choose between a DOS or a Linux partition as
the boot source partition. LILO is included with Red Hat Linux and is installed automaically when you load the system from CD-ROM.
Some of the features of LILO include the following:
Using LILO may seem risky at first; it can ruin your hard drive or leave you with a system that you cannot boot. To prepare yourself for this mishap, keep a boot disk handy. Also, you have to do this installation as root, so be careful.
If you have already installed Red Hat Linux, the LILO files will exist on your hard drive. If you are about to install Red Hat Linux, the LILO installation routine will be activated automatically as part of the installation process. If you want to redo
the LILO system at any time, though, you can run the program /sbin/liloconfig.
The liloconfig program is easy to use and asks several questions about your system. The sheer number of possibilities cannot be completely covered here, but here are the terms with which you must be familiar:
The liloconfig program asks you where you want to install LILO. If you are running multiple operating systems and plan to switch between them often, try installing on the Linux partition superblock. If you will use Linux primarily or only, install on
the Master Boot Record. You will then be asked about the ability to load other operating systems from the boot prompt, and you get to identify each operating system and provide a name for it. This lets you start DOS, for example, from the boot prompt by
entering the name you assigned to DOS partition.
After the liloconfig program has run, it will create a file called lilo.conf for you in the /etc directory. If you already have this file in your /etc directory, you can edit it manually using any ASCII editor. Of course, depending on how your system is
set up, the contents of your Linux installation may vary. A sample lilo.conf file for a system containing both DOS and Linux looks like this:
boot=/dev/hda map=/boot/map install=/boot/boot.b prompt timeout=50 image=/vmlinuz root=/dev/hda2 label=linux other=/dev/hda1 label=dos table=/dev/hda
In this lilo.conf file, you can see two different kernels that can be booted from /dev/hda. The first image is the default image, called vmlinuz. The other image is labeled DOS for the DOS partition. Typing dos at the boot prompt will boot this
The LILO configuration is written to disk using the /sbin/lilo command. The /sbin/lilo installer accepts several command-line options. A few of the more usual ones are listed here.
The /etc/lilo.conf file can have the following parameters. All of these can be set from the command line, but storing them in a configuration file is more reliable. The following options are available to you:
<port>. The number of the serial port, zero-based. 0 corresponds to COM1.
alias /dev/ttyS0, alias /dev/ttys1, alias /dev/ttys2, alias /dev/ttys3. All four ports can be used (if present).
<bps>. The baud rate of the serial port. The following baud rates are supported: 110, 150, 300, 600, 1200, 2400, 4800, and 9600 bps. Default is 2400 bps.
<parity>. The parity used on the serial line. LILO ignores input parity and strips the eighth bit. The following (upper- or lowercase) characters are used to describe the parity: n for no parity, e for even parity, and o for odd parity.
<bits>. The number of bits in a character. Only 7 and 8 bits are supported. Default is 8 if parity is none, 7 if parity is even or odd.
fix-table does not guarantee that other operating systems might not attempt to reset the address later. It is also possible that this change has other, unexpected side effects. The correct fix is to repartition the drive with a program that does align partitions to tracks.
The kernel configuration parameters append, ramdisk, read-only, read-write, root, and vga can be set in the options section. They are used as defaults if they aren't specified in the configuration sections of the respective kernel images.
If the option -q is specified on the command line, the currently mapped files are listed. Otherwise, a new map is created for the images described in the configuration file /etc/lilo/config and they are written to in the boot sector.
When the system boots up, after the keyboard test, press and hold down one of any one of these keys: Alt, Shift, or Ctrl (or you can set the Caps Lock or Scroll Lock key). If any of these keys are pressed, LILO displays the boot: prompt and waits for
the name of a boot image. Pressing the Tab key or typing ? gives you a list of names recognized by LILO. If you do not press any of these keys, LILO will boot up the first it finds in the lilo.conf file kernel (in this case, vmlinuz.cd) if there is no
timeout specified in the /etc/lilo.conf file.
LILO can also pass command-line options to the kernel. Command-line options are words that follow the name of the boot image and are separated by spaces. Currently, the kernel recognizes the options root=<device>, ro, and rw, and all current init
programs also recognize the option single, which boots the system in single-user mode. This bypasses all system-initialization procedures and directly starts a root shell on the console. Multiuser mode can be entered by exiting the single-user shell or by
The option vga is processed by the boot loader itself. The option vga=<mode> alters the VGA mode that was set at startup. The legal values for mode are NORMAL, EXTENDED, ASK, or a decimal number for the BIOS mode command. You can get a list of
available modes by typing vga=ask and pressing Enter.
The root=<device> option changes the root device. This overrides settings that may have been made in the boot image and on the LILO command line.
<device> is either a hexadecimal device number or the full pathname of the device, such as /dev/hda3. (The device names are hard-coded in the kernel.)
ro instructs the kernel to mount the root file system as read-only. rw mounts it as read-write. If neither ro nor rw is specified, the setting from the boot image is used.
The no387 option disables using the hardware FPU.
Depending on the kernel configuration, some special configuration options for nonstandard hardware might be recognized as well. Some of these boot prompts include the following :
The parameters for each type of device will come with their documentation, so do not assume anything. Use only specified values. If you do follow instructions, you may wind up causing irrecoverable errors, which may lead to a corrupt file system.
In order to keep LILO from being invoked when the system boots, its boot sector has to be either removed or disabled. All other files belonging to LILO can be deleted after removing the boot sector, if desired.
LILO 0.14 (and newer) can be uninstalled with the lilo -u command.
If LILO's boot sector has been installed on a primary partition and is booted by the standard MBR or some partition-switching program, it can be disabled by making a different partition active. MS-DOS's FDISK, Linux's fdisk, or LILO's activate can do
If LILO's boot sector is the Master Boot Record (MBR) of a disk, it has to be replaced with a different MBR, typically MS-DOS's standard MBR. When using MS-DOS 5.0 or above, the MS-DOS MBR can be restored with FDISK /MBR. This alters only the boot
loader code, not the partition table. LILO automatically makes backup copies when it overwrites boot sectors. They are named /etc/lilo/boot.<nnnn>, with <nnnn> corresponding to the device numberthat is, 0300 is /dev/hda, 0800 is /dev/sda,
and so on. Those backups can be used to restore the old MBR if no easier method is available.
The commands are
dd if=/etc/lilo/boot.0300 of=/dev/hda bs=446 count=1
dd if=/etc/lilo/boot.0800 of=/dev/sda bs=446 count=1
Some other operating systems (such as MS-DOS 6.0) appear to modify the MBR in their install procedures. It is therefore possible that LILO will cease to work after such an installation and Linux has to be booted from floppy disk. The original state can be restored by either rerunning /etc/lilo/lilo (if LILO is installed as the MBR) or by making LILO's partition active (if it's installed on a primary partition).
Typically, the new operating system then has to be added to LILO's configuration (and /etc/lilo/lilo has to be rerun) in order to boot it.
Some messages that indicate common errors when installing the maps are as follows:
When LILO loads itself, it displays the word LILO. Each letter is printed before or after performing some specific action. If LILO fails at some point, the letters printed so far can be used to identify the problem. This is described in more detail in
the technical overview.
Note that some hex digits may be inserted after the first L if a transient disk problem occurs. Unless LILO stops at that point, generating an endless stream of error codes, such hex digits do not indicate a severe problem. The following is the list of
error messages you can see:
(nothing) No part of LILO has been loaded. LILO either isn't installed, or the partition on which its boot sector is located isn't active.
L<error> The first stage boot loader has been loaded and started, but it can't load the second stage boot loader. The two-digit error codes indicate the type of problem. (They are described in the next section.) This condition usually indicates a
media failure or a geometry mismatch (that is, bad parameters in /etc/lilo/disktab).
LI The first-stage boot loader was able to load the second-stage boot loader but has failed to execute it. This can be caused either by a geometry mismatch or by moving /etc/lilo/boot.b without running the map installer.
LIL The second-stage boot loader has been started, but it can't load the descriptor table from the map file. This is typically caused by a media failure or a geometry mismatch.
LIL? The second-stage boot loader has been loaded at an incorrect address. This is typically caused by a subtle geometry mismatch or by moving /etc/lilo/boot.b without running the map installer.
LIL- The descriptor table is corrupt. This can be caused either by a geometry mismatch or by moving /etc/lilo/map without running the map installer.
LILO All parts of LILO have been successfully loaded.
There are also BIOS error codes that you might get while loading LILO. These are listed in Table 4.1.
|0x00||Internal error. This code is generated by the sector-read routine of the LILO boot loader whenever an internal inconsistency is detected. This might be caused by corrupt files; try rebuilding the map file.|
|0x01||Illegal command. This shouldn't happen.|
|0x02||Address mark not found. This usually indicates a media problem. Try again several times.|
|0x03||Write-protected disk. This shouldn't happen.|
|0x04||Sector not found. This typically indicates a geometry mismatch. If you're booting a raw-written disk image, verify whether it was created for disks with the same geometry as the one you're using. If you're booting from a SCSI disk, you should check whether LILO has obtained correct geometry data from the kernel or whether the contents of your /etc/lilo/disktab file correspond to the real disk geometry. Removing compact may help too.|
|0x06||Change line active. This should be a transient error. Try booting a second time.|
|0x08||DMA overrun. This shouldn't happen. Try booting again.|
|0x09||DMA attempt across 64KB boundary. This shouldn't happen. Try omitting the -c option.|
|0x0C||Invalid media. This shouldn't happen and might be caused by a media error. Try booting again.|
|0x10||CRC error. A media error has been detected. Try booting several times, running the map installer a second time (to put the map file at some other physical location or to write good data over the bad spot), mapping out the bad sectors/tracks, and, if all else fails, replacing the media.|
|0x20||Controller error. This shouldn't happen.|
|0x40||Seek failure. This might be a media problem. Try booting again.|
|0x80||Disk timeout. The disk or the drive isn't ready. Either the media is bad or the disk isn't spinning. If you're booting from a floppy, you might not have closed the drive door. Otherwise, trying to boot again might help.|
Now when you reboot, the BOOT.SYS and BOOTLIN.SYS files will boot into Linux for you.
To get back to running only DOS, remove the BOOTLIN.SYS and BOOT.SYS from your config.sys file.
If you want to restore the MBR to the original DOS MBR, you can use the following procedure:
This chapter covered the topic of installing, configuring, and using LILO. It also covered some of the basic errors you can face and how to set up LILO using the liloconfig utility. The information you have learned from this topic should get you started in setting up LILO to boot Linux on your machine off the hard drive.