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


Book HomeLinux in a NutshellSearch this book

4.2. 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 95/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 NT is not quite as straightforward, because Windows NT 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 NT loader transfers control to LILO, which then boots Linux. The same applies to Windows 2000, which uses the NT loader. See Section 4.4, "Dual Booting Linux and Windows NT/2000" later in this chapter for more information.

In addition to booting Linux, LILO can boot other operating systems, such as MS-DOS, Windows 95/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:

  • Boot Linux from a floppy disk and restore the backed-up boot sector:

    % /sbin/lilo -u

  • Boot to DOS and run a special version of the fdisk command that rebuilds the MBR:

    C:> fdisk /mbr

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 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 95
other=/dev/hda1
  label=win95
  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 in Section 4.2.1.3, "Kernel options" later) also can be set as global options.

backup=backup-file

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

boot=boot-device

Sets 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.

compact

Merges 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

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

delay=tsecs

Specifies, 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 20 at a minimum. The default is to not wait.

disk=device-name

Defines 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. The parameters that can be specified with disk are listed briefly here. They are described in detail in the LILO User's Guide, which comes with the LILO distribution.

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

Tells 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.

partition=partition-device

Starts 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, allows 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 overwrites an old backup copy if one exists.

ignore-table

Tells lilo to ignore corrupt partition tables.

install=boot-sector

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

lba32

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

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

linear

Generates 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

Tells 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 is a set of options that you need to enter on the boot command line every time you boot the system.

map=map-file

Specifies the location of the map file. Defaults to /boot/map.

message=message-file

Specifies 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

Disables warning messages.

optional

Specifies 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

Specifies 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 displays 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

Allows 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

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

timeout=tsecs

Sets 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

Turns 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 for a particular image.

alias=name

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

image=pathname

Specifies 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

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

loader=chain-loader

For a non-Linux operating system, specifies 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 chain loader must be specified.

lock

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

optional

Specifies 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.

password=password

Specifies that the image is password-protected and provides 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

Specifies that a password is required for booting the image only if boot parameters are specified on the command line.

table=device

Specifies, 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

Appends the options specified in string to the parameter line passed to the kernel. This typically is used to specify certain hardware parameters. For example, if your system has more than 64 MB of memory (i.e., more than your BIOS can recognize), you can use append:

     append = "mem=128M"
initrd=filename

Specifies the file to load into /dev/initrd when booting with a RAM disk. See also the options load_ramdisk (in Section 4.5, "Boot-time Kernel Options"), prompt_ramdisk, ramdisk_size, and ramdisk_start (in Section 4.6, "initrd: Using a RAM Disk").

literal=string

Like append but replaces all other kernel boot options.

noinitrd

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

prompt_ramdisk=n

Specifies 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.5, "Boot-time Kernel Options" as well as prompt_ramdisk, ramdisk_size, and ramdisk_start, elsewhere in this section.

ramdisk_size=n

Specifies 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.

root=root-device

Specifies 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

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

ask

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

extended (or ext)

Selects 80x50 text mode.

normal

Selects 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 those lilo command options that are available only on the command line. Multiple options are given separately:

% lilo -q -v
-C config-file

Specifies 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

Prints 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

Lists the currently mapped files. lilo maintains a file (by default /boot/map), 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 (in which the asterisk indicates that linux is the default):

% lilo -q
linux     *
test

-r root-directory

Specifies 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

Sets 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

Indicates that this is a test. Does 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

Uninstalls 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 does not check the timestamp.

-V

Prints the lilo version number.



Library Navigation Links

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