home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Linux in a NutshellLinux in a NutshellSearch this book

4.2. LILO: The Linux Loader

In addition to booting Linux, LILO can boot other operating systems, such as MS-DOS, Windows 95/98/ME, or any of the BSD systems. 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 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.

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.

4.2.1. 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 these 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=win98
   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 98
other=/dev/hda1
  label=win98
  loader=/boot/chain.b
  table=/dev/hda

4.2.1.1. Global options

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

backup=backup-file
Copy the original boot sector to backup-file instead of to /boot/boot.nnnn, where nnnn is a number that depends on the disk device type.

boot=boot-device
Set the name of the device that contains the boot sector. boot defaults to the device currently mounted as root, such as /dev/hda2. Specifying a device such as /dev/hda (without a number) indicates that LILO should be installed in the master boot record; the alternative is to set it up on a particular partition such as /dev/hda2.

change-rules
Begin a section that redefines partition types at boot time for hiding and unhiding partitions. See the LILO User's Guide, which comes with the LILO distribution, for detailed information on using this option and creating a new rule set.

compact
Merge read requests for adjacent disk sectors to speed up booting. Use of compact is particularly recommended when booting from a floppy disk. Use of compact may conflict with linear.

default=name
Use the image name as the default boot image. If default is omitted, the first image specified in the configuration file is used.

delay=tsecs
Specify, in tenths of a second, how long the boot loader should wait before booting the default image. If serial is set, delay is set to a minimum of 20. The default is not to wait. See Section 4.7 at the end of this chapter for ways to get the boot prompt if no delay is set.

disk=device-name
Define parameters for the disk specified by device-name if LILO can't figure them out. Normally, LILO can determine the disk parameters itself and this option isn't needed. When disk is specified, it is followed by one or more parameter lines, such as:

disk=/dev/sda
  bios=0x80      # First disk is usually 0x80, second is usually 0x81
  sectors=...
  heads=...

Note that this option is not the same as the disk geometry parameters you can specify with the hd boot command-line option. With disk, the information is given to LILO; with hd, it is passed to the kernel. Note also that if either heads or sectors is specified, they must both be specified. The parameters that can be specified with disk are listed briefly here; they are described in detail in the LILO User's Guide.

bios=bios-device-code
The number the BIOS uses to refer to the device. See the previous example.

cylinders=cylinders
The number of cylinders on the disk.

heads=heads
The number of heads on the disk.

inaccessible
Tell LILO that the BIOS can't read the disk; used to prevent the system from becoming unbootable if LILO thinks the BIOS can read it. If this parameter is specified, it must be the only parameter.

partition=partition-device
Start a new section for a partition. The section contains one variable, start=partition-offset, which specifies the zero-based number of the first sector of the partition:

partition=/dev/sda1
  start=2048
sectors=sectors
The number of sectors per track.

disktab=disktab-file
This option has been superseded by the disk= option.

fix-table
If set, allow lilo to adjust 3D addresses (addresses specified as sector/head/cylinder) in partition tables. This is sometimes necessary if a partition isn't track-aligned and another operating system such as MS-DOS is on the same disk. See the lilo.conf manpage for details.

force-backup=backup-file
Like backup, but overwrite an old backup copy if one exists.

ignore-table
Tell lilo to ignore corrupt partition tables.

install=boot-sector
Install the specified file as the new boot sector. If install is omitted, the boot sector defaults to /boot/boot.b.

lba32
Generate 32-bit Logical Block Addresses instead of sector/head/cylinder addresses, allowing booting from any partition on hard disks greater than 8.4 GB (i.e., remove the 1024-cylinder limit). Requires BIOS support for the EDD packet call interface[4] and at least LILO Version 21-4.

[4]If your BIOS is dated after 1998, it should include EDD packet call interface support.

linear
Generate linear sector addresses, which do not depend on disk geometry, instead of 3D (sector/head/cylinder) addresses. If LILO can't determine your disk's geometry itself, you can try using linear; if that doesn't work, then you need to specify the geometry with disk=. Note, however, that linear sometimes doesn't work with floppy disks, and it may conflict with compact.

lock
Tell LILO to record the boot command line and use it as the default for future boots until it is overridden by a new boot command line. lock is useful if there are kernel options that you need to enter on the boot command line every time you boot the system.

map=map-file
Specify the location of the map file. Defaults to /boot/map.

message=message-file
Specify a file containing a message to be displayed before the boot prompt. The message can include a formfeed character (Ctrl-L) to clear the screen. The map file must be rebuilt by rerunning the lilo command if the message file is changed or moved. The maximum length of the file is 65,535 bytes.

nowarn
Disable warning messages.

optional
Specify that any image that is not available when the map is created should be omitted and not offered as an option at the boot prompt. Like the per-image option optional but applies to all images.

password=password
Specify a password that the user is prompted to enter when trying to load an image. The password is not encrypted in the configuration file, so if passwords are used, permissions should be set so that only the superuser is able to read the file. This option is like the per-image version, except that all images are password-protected and they all have the same password.

prompt
Automatically display the boot prompt without waiting for the user to press the Shift, Alt, or Scroll Lock key. Note that setting prompt without also setting timeout prevents unattended reboots.

restricted
Can be used with password to indicate that a password needs to be entered only if the user specifies parameters on the command line. Like the per-image restricted option but applies to all images.

serial=parameters
Allow the boot loader to accept input from a serial line as well as from the keyboard. Sending a break on the serial line corresponds to pressing a Shift key on the console to get the boot loader's attention. All boot images should be password-protected if serial access is insecure (e.g., if the line is connected to a modem). Setting serial automatically raises the value of delay to 20 (i.e., 2 seconds) if it is less than that. The parameter string parameters has the following syntax:

port[,bps[parity[bits]]]

For example, to initialize COM1 with the default parameters:

serial=0,2400n8

The parameters are:

port
The port number of the serial port. The default is 0, which corresponds to COM1 (/dev/ttys0). The value can be one of 0 through 3, for the four possible COM ports.

bps
The baud rate of the serial port. Possible values of bps are 110, 300, 1200, 2400, 4800, 9600, 19200, and 38400. The default is 2400 bps.

parity
The parity used on the serial line. Parity is specified as n or N for no parity, e or E for even parity, and o or O for odd parity. However, the boot loader ignores input parity and strips the 8th bit.

bits
Specify whether a character contains 7 or 8 bits. Default is 8 with no parity and 7 otherwise.

timeout=tsecs
Set a timeout (specified in tenths of a second) for keyboard input. If no key has been pressed after the specified time, the default image is booted automatically. timeout is also used to determine when to stop waiting for password input. The default timeout is infinite.

verbose=level
Turn on verbose output, where higher values of level produce more output. If -v is also specified on the lilo command line, the level is incremented by 1 for each occurrence of -v. The maximum verbosity level is 5.

4.2.1.2. Image options

The following options are specified in the image section for a particular boot image. The image can be a Linux kernel or a non-Linux operating system.

alias=name
Provide an alternate name for the image that can be used instead of the name specified with the label option.

image=pathname
Specify the file or device containing the boot image of a bootable Linux kernel. Each per-image section that specifies a bootable Linux kernel starts with an image option. See also the range option.

label=name
Specify the name that is used for the image at the boot prompt. Defaults to the filename of the image file (without the path).

loader=chainloader
For a non-Linux operating system, specify the chain loader to which LILO should pass control for booting that operating system. The default is /boot/chain.b. If the system will be booted from a drive that is neither the first hard disk or a floppy, the chainloader must be specified.

lock
Like lock as described in the previous global options section; it can also be specified in an image section.

optional
Specify that the image should be omitted if it is not available when the map is created by the lilo command. Useful for specifying test kernels that are not always present.

other=pathname
Specify the path to a file that boots a non-Linux system. Each per-image section that specifies a bootable non-Linux system starts with an other option.

password=password
Specify that the image is password-protected and provide the password that the user is prompted for when booting. The password is not encrypted in the configuration file, so if passwords are used, only the superuser should be able to read the file.

range=sectors
Used with the image option, when the image is specified as a device (e.g., image=/dev/fd0), to indicate the range of sectors to be mapped into the map file. sectors can be given as the range start-end or as start+number, where start and end are zero-based sector numbers and number is the increment beyond start to include. If only start is specified, only that one sector is mapped. For example:

image=/dev/fd0
range=1+512   # take 512 sectors, starting with sector 1
restricted
Specify that a password is required for booting the image only if boot parameters are specified on the command line.

table=device
Specify, for a non-Linux operating system, the device that contains the partition table. If table is omitted, the boot loader does not pass partition information to the operating system being booted. Note that /sbin/lilo must be rerun if the partition table is modified. This option cannot be used with unsafe.

unsafe
Can be used in the per-image section for a non-Linux operating system to indicate that the boot sector should not be accessed when the map is created. If unsafe is specified, then some checking isn't done, but the option can be useful for running the lilo command without having to insert a floppy disk when the boot sector is on a fixed-format floppy disk device. This option cannot be used with table.

4.2.1.3. Kernel options

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

append=string
Append the options specified in string to the parameter line passed to the kernel. This typically is used to specify certain hardware parameters. For example, while BIOSes on newer systems can recognize more than 64 MB of memory, BIOSes on older systems are limited to 64 MB. If you are running Linux on such a system, you can use append:

append="mem=128M"
initrd=filename
Specify the file to load into /dev/initrd when booting with a RAM disk. See also the options load_ramdisk (in Section 4.7), and prompt_ramdisk, ramdisk_size, and ramdisk_start in this section.

literal=string
Like append, but replace all other kernel boot options.

noinitrd
Preserve the contents of /dev/initrd so they can be read once after the kernel is booted.

prompt_ramdisk=n
Specify whether the kernel should prompt you to insert the floppy disk that contains the RAM disk image, for use during Linux installation. Values of n are:

0
Don't prompt. Usually used for an installation in which the kernel and the RAM disk image both fit on one floppy.

1
Prompt. This is the default.

ramdisk=size
Obsolete; use only with kernels older than Version 1.3.48. For newer kernels, see the option load_ramdisk in Section 4.7, as well as prompt_ramdisk, ramdisk_size, and ramdisk_start in this section.

ramdisk_size=n
Specify the amount of memory, in kilobytes, to be allocated for the RAM disk. The default is 4096, which allocates 4 megabytes.

ramdisk_start=offset
Used for a Linux installation in which both the kernel and the RAM disk image are on the same floppy. offset indicates the offset on the floppy where the RAM disk image begins; it is specified in kilobytes.

read-only
Specify that the root filesystem should be mounted read-only for filesystem checking (fsck), after which it is typically remounted read/write.

read-write
Specify that the root filesystem should be mounted read/write.

root=root-device
Specify the device that should be mounted as root. If the special name current is used as the value, the root device is set to the device on which the root filesystem currently is mounted. Defaults to the root-device setting contained in the kernel image.

vga=mode
Specify the VGA text mode that should be selected when booting. The mode defaults to the VGA mode setting in the kernel image. The values are case-insensitive. They are:

ask
Prompt the user for the text mode. Pressing Enter in response to the prompt displays a list of the available modes.

extended (or ext)
Select 80x50 text mode.

normal
Select normal 80x25 text mode.

number
Use the text mode that corresponds to number. A list of available modes for your video card can be obtained by booting with vga=ask and pressing Enter.

4.2.3. lilo Command Options

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

% lilo -q -v
-C config-file
Specify an alternative to the default configuration file (/etc/lilo.conf). lilo uses the configuration file to determine what files to map when it installs LILO.

-I label
Print the path to the kernel specified by label to standard output, or an error message if no matching label is found. For example:

% lilo -I linux
/boot/vmlinuz-2.0.34-0.6
-q
List the currently mapped files. lilo maintains a file (/boot/map by default) containing the name and location of the kernel(s) to boot. Running lilo with this option prints the names of the files in the map file to standard output, as in this example (the asterisk indicates that linux is the default):

% lilo -q
linux     *
test
-r root-directory
Specify that before doing anything else, lilo should chroot to the indicated directory. Used for repairing a setup from a boot floppy—you can boot from a floppy but have lilo use the boot files from the hard drive. For example, if you issue the following commands, lilo will get the files it needs from the hard drive:

% mount /dev/hda2 /mnt
% lilo -r /mnt
-R command-line
Set the default command for the boot loader the next time it executes. The command executes once and then is removed by the boot loader. This option typically is used in reboot scripts, just before calling shutdown -r.

-t
Indicate that this is a test—do not really write a new boot sector or map file. Can be used with -v to find out what lilo would do during a normal run.

-u device-name
Uninstall lilo by restoring the saved boot sector from /boot/boot.nnnn, after validating it against a timestamp. device-name is the name of the device on which LILO is installed, such as /dev/hda2.

-U device-name
Like -u, but do not check the timestamp.

-V
Print the lilo version number.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.