\documentstyle[fullpage]{article}

\parindent=0pt
\parskip=4pt

\hyphenation{hexa-decimal}

% Okay, what follows is more TeX than LaTeX ...

\def\hditem#1{\hbox to 1.2in{#1\hfil}}
\def\boottwo#1{$$
  \bf
  \begin{tabular}{|ll|}
    \hline
    \hditem{\rm Master Boot Record} & \hditem{\rm Operating system} \\
    \hline
    #1 \\
    \hline
  \end{tabular}
  $$}

\def\bootthree#1{$$
  \bf
  \begin{tabular}{|lll|}
    \hline
    \hditem{\rm Master Boot Record} & \hditem{\rm Boot sector} &
      \hditem{\rm Operating system} \\
    \hline
    #1 \\
    \hline
  \end{tabular}
  $$}

\def\bootfour#1{$$
  \bf
  \begin{tabular}{|llll|}
    \hline
    \hditem{\rm Master Boot Record} & \hbox to 1.1in{\rm Boot sector\hfil} &
      \hditem{\rm Operating systems} & \hbox to 0.4in{\hfil} \\
    \hline
    #1 \\
    \hline
  \end{tabular}
  $$}
\def\sep{\rightarrowfill &}
\def\empty{&}
\def\branch{\hfill$\longrightarrow$ &}
\def\cont{---\,$\cdots$}
\def\key#1{$[$#1$]$}
\def\LILO{LILO}

\begin{document}

\title{\LILO \\
  \Large
  Generic boot loader for Linux \\
  Version 0.14 \\ ~\\
  \bf User's guide}
\author{Werner Almesberger \\
  {\tt almesber@bernina.ethz.ch}}

\maketitle
{
  \parskip=-4pt
  \setcounter{tocdepth}{1}
  \tableofcontents
}

~\\
\LILO\ is a versatile boot loader for Linux. It does not depend on a specific
file system, can boot Linux kernel images from
floppy disks and from hard disks and can even boot other operating
systems\footnote{PC/MS-DOS, DR DOS, OS/2, 386BSD, SCO UNIX, $\ldots$}.

One of up to sixteen different images can be selected at boot time.
Various parameters, such as the root
device, can be set independently for each kernel. \LILO\ can even be
used as the master boot record.

This document introduces the basics of disk organization and booting,
continues with an overview of common boot techniques and finally describes
installation and use of \LILO\ in greater detail. The troubleshooting
section at the end describes diagnostic messages and contains suggestions
for most problems that have been observed in the past.

Please read the sections about installation and configuration if you're
already using an older version of \LILO. This distribution is accompanied
by a file named {\tt INCOMPAT} that describes further incompatibilities
to older versions.

For the impatient: there is a quick-installation script that creates
a simple but quite usable installation. See section \ref{quickinst} for
details.


\newpage
\section{Disk organization}

When designing a boot concept, it is important to understand all the
subtleties of how MS-DOS organizes disks. The most simple case are
floppy disks. They consist of a boot sector, some administrative
data (FAT or super block, etc.) and the data area. Because that
administrative data is irrelevant as far as booting is concerned, it is
regarded as part of the data area for simplicity.

$$
\begin{tabular}{|c|c|}
  \hline
  Boot sector & \hbox to 1.5in{\hfil} \\
  \cline{1-1}
  \multicolumn{2}{|c|}{} \\
  \multicolumn{2}{|c|}{Data area} \\
  \multicolumn{2}{|c|}{} \\
  \hline
  \end{tabular}
$$

The entire disk appears as one device (i.e. {\tt /dev/fd0}) on Linux.

The MS-DOS boot sector has the following structure:

$$
\begin{tabular}{r|c|}
  \cline{2-2}
  \tt 0x000 & Jump to the program code\\
  \cline{2-2}
  \tt 0x003 & \\
  & Disk parameters \\
  & \\
  \cline{2-2}
  \tt 0x02C/0x03E & \\
  & Program code \\
  & \\
  & \\
  \cline{2-2}
  \tt 0x1FE & Magic number (0xAA55)\\
  \cline{2-2}
\end{tabular}
$$

\LILO\ uses a similar boot sector, but it does not contain the disk
parameters part. This is no problem for Minix, Ext2 or similar file systems,
because
they don't look at the boot sector, but putting a \LILO\ boot sector on an
MS-DOS file system would make it inaccessible for MS-DOS.

Hard disks are organized in a more complex way than floppy disks. They
contain several data areas called partitions. Up to four so-called
primary partitions can exist on an MS-DOS hard disk. If more partitions
are needed, a primary partition is used as an extended partition that
contains several logical partitions.

The first sector of each hard disk contains a partition table and an
extended partition and {\bf each} logical partition contains a partition
table too.

$$
\begin{tabular}{|l|l|l|}
  \hline
  \multicolumn{3}{|l|}{Partition table\hbox to 2in{\hfil\tt /dev/hda~}} \\
  \cline{2-3}
  & \multicolumn{2}{l|}{Partition 1\hfill {\tt /dev/hda1}} \\
  & \multicolumn{2}{l|}{} \\
  \cline{2-3}
  & \multicolumn{2}{l|}{Partition 2\hfill {\tt /dev/hda2}} \\
  & \multicolumn{2}{l|}{} \\
  \hline
\end{tabular}
$$

The entire disk can be accessed as {\tt /dev/hda}, {\tt /dev/hdb},
{\tt /dev/sda}, etc. The primary partitions are {\tt /dev/hda1 $\ldots$
/dev/hda4}.

$$
\begin{tabular}{|l|l|l|}
  \hline
  \multicolumn{3}{|l|}{Partition table\hbox to 2in{\hfil\tt /dev/hda~}} \\
  \cline{2-3}
  & \multicolumn{2}{l|}{Partition 1\hfill {\tt /dev/hda1}} \\
  & \multicolumn{2}{l|}{} \\
  \cline{2-3}
  & \multicolumn{2}{l|}{Partition 2\hfill {\tt /dev/hda2}} \\
  & \multicolumn{2}{l|}{} \\
  \cline{2-3}
  & \multicolumn{2}{l|}{Extended partition\hfill {\tt /dev/hda3}} \\
  \cline{3-3}
  & & Extended partition table \\
  \cline{3-3}
  & & Partition 3\hfill {\tt /dev/hda5}\\
  & & \\
  \cline{3-3}
  & & Extended partition table \\
  \cline{3-3}
& & Partition 4\hfill {\tt /dev/hda6}\\
  & & \\
  \hline
\end{tabular}
$$

This hard disk has two primary partitions and an extended partition
that contains two logical partitions. They are accessed as
{\tt /dev/hda5 $\ldots$}

Note that the partition tables of logical partitions are not accessible
as the first blocks of some devices, while the main partition table,
all boot sectors and the partition tables of extended partitions are.

Partition tables are stored in partition boot sectors. Normally, only the
partition boot sector of the entire disk is used as a boot sector. It is
also frequently called the master boot record (MBR).

$$
\begin{tabular}{r|c|}
  \cline{2-2}
  \tt 0x000 & \\
  & Program code \\
  & \\
  & \\
  \cline{2-2}
  \tt 0x1BE & Partition table \\
  & \\
  \cline{2-2}
  \tt 0x1FE & Magic number (0xAA55) \\
  \cline{2-2}
\end{tabular}
$$

The \LILO\ boot sector is designed to be usable as a partition boot sector.
(I.e. there is room for the partiton table.)
Therefore, the \LILO\ boot sector can be stored at the following locations:

\begin{itemize}
  \item boot sector of a Linux floppy disk. ({\tt /dev/fd0}, $\ldots$)
  \item MBR of the first hard disk. ({\tt /dev/hda}, $\ldots$)
  \item boot sector of a primary Linux file system partition on the first hard
    disk. ({\tt /dev/hda1}, $\ldots$)
  \item partition boot sector of an extended partition on the first hard disk.
    ({\tt /dev/hda1}, $\ldots$)\footnote{Most FDISK-type programs don't
      believe in booting from an extended partition and refuse to
      activate it. \LILO\ is accompanied by a simple program
      ({\sf activate}) that doesn't have this restriction. Recent versions
      of Linux {\sf fdisk} also support activating extended partitions.}
\end{itemize}

It {\bf can't} be stored at any of the following locations:

\begin{itemize}
  \item boot sector of a non-Linux floppy disk or primary partition.
  \item a Linux swap partition.
  \item boot sector of a logical partition in an extended partition.%
\footnote{\LILO\ can be forced to put the boot sector on such a
 partition by using the {\tt -b} option or the {\tt boot} variable.
 However, hardly any programs that operate as master boot records
 support booting from a logical partition.}
  \item on the second hard disk. (Unless for backup installations,
    if the current first disk will be removed or disabled, or if some
    other boot loader is used, that is capable of loading boot sectors from
    other drives.)
\end{itemize}

\LILO\ typically doesn't detect attempts to put its boot sector at an
invalid location.


\newpage
\section{Booting basics}

When booting from a floppy disk, the first sector of the disk, the so-called
boot sector, is loaded. That boot sector contains a small program that loads
the respective operating system. MS-DOS boot sectors also contain 
a data area, where disk and file system parameters (cluster size, number of
sectors, number of heads, etc.) are stored.

When booting from a hard disk, the very first sector of that disk, the
so-called master boot record (MBR) is loaded. This sector contains a
loader program and the partition table of the disk. The loader program
usually loads the boot sector, as if the system was booting from a floppy.

Note that there is no functional difference between the MBR and the boot
sector other than that the MBR contains the partition information but
doesn't contain any (MS-DOS) disk parameter information.

The first 446 (0x1BE) bytes of the MBR are used by the loader program.
They are followed by the partition table, with a length of 64 (0x40)
bytes. The last two bytes contain a magic number that is sometimes used to
verify that a given sector really is a boot sector.

There is a large number of possible boot configurations. The most common
ones are described in the following sections.


\subsection{MS-DOS alone}

\bootthree{DOS-MBR \sep MS-DOS \sep COMMAND.COM}

This is what usually happens when MS-DOS boots from a hard disk: the DOS-MBR
determines the active partition and loads the MS-DOS boot sector. This boot
sector loads MS-DOS and finally passes control to {\tt COMMAND.COM}. (This is
greatly simplified.)


\subsection{BOOTLIN}

\bootfour{DOS-MBR \sep MS-DOS \sep COMMAND.COM \empty \\
  \empty \branch BOOTLIN \sep Linux}

A typical {\sf BOOTLIN} setup: everything happens like when booting MS-DOS,
but in {\tt CONFIG.SYS} or {\tt AUTOEXEC.BAT}, BOOTLIN is invoked. Typically,
a program like {\tt BOOT.SYS} is used to choose among configuration sections
in {\tt CONFIG.SYS} and {\tt AUTOEXEC.BAT}.
This approach has the pleasant property that no boot
sectors have to be altered.

Installation:
\begin{itemize}
  \item boot Linux.
  \item copy a bootable kernel image to your MS-DOS partition.\footnote{%
    With Mtools or the MS-DOS FS.}
  \item install {\tt BOOT.SYS} and {\tt BOOTLIN.SYS} on your MS-DOS
    partition and add them to your {\tt CONFIG.SYS}.
    (The READMEs describe how this is done.)
  \item reboot.
\end{itemize}

Deinstallation:
\begin{itemize}
  \item remove {\tt BOOT.SYS} and {\tt BOOTLIN.SYS} from your {\tt CONFIG.SYS}.
\end{itemize}


\subsection{\LILO\ started by DOS-MBR}

\bootthree{DOS-MBR \sep LILO \sep Linux \\
  \branch {\rm other OS} \empty}

This is a ``safe'' \LILO\ setup: \LILO\ is booted by the DOS-MBR. No other boot
sectors have to be touched. If the other OS (or one of them, if there are
several other operating systems being used) should be booted without
using \LILO, the other
partition has to be marked ``active'' with {\sf fdisk} or {\sf activate}.

Installation:
\begin{itemize}
  \item install \LILO\ with its boot sector on the Linux partition.
  \item use {\sf fdisk} or {\sf activate} to make that partition active.
  \item reboot.
\end{itemize}

Deinstallation:
\begin{itemize}
  \item make a different partition active.
  \item install whatever should replace \LILO\ or Linux.
\end{itemize}


\subsection{Several alternate branches}

\bootfour{DOS-MBR \sep MS-DOS \sep COMMAND.COM \empty \\
  \empty \branch BOOTLIN \sep Linux \\
  \branch LILO \sep Linux \empty \\
  \empty \branch MS-DOS \cont \empty}

An extended form of the above setup: the MBR is not changed and both branches
can either boot Linux or MS-DOS. (\LILO\ could also boot any other
operating system.)


\subsection{\LILO\ started by {\sf BOOTACTV}}

\bootthree{BOOTACTV \sep LILO \sep Linux \\
  \branch {\rm other OS} \empty}

Here, the MBR is replaced by {\sf BOOTACTV} (or any other interactive boot
partition selector) and the choice between Linux and the
other operating system(s) can be made at boot time. This approach should be
used if \LILO\ fails to boot the other operating system(s).\footnote{%
And the author would like to be notified if booting the other operating
system(s) doesn't work with \LILO, but if it works with an other boot partition
selector.}

Installation:
\begin{itemize}
  \item boot Linux.
  \item make a backup copy of your MBR on a floppy disk, e.g. \\
    \verb"dd if=/dev/hda of=/fd/MBR bs=512 count=1"
  \item install \LILO\ with the boot sector on the Linux partition.
  \item install {\sf BOOTACTV} as the MBR, e.g. \\
    \verb"dd if=bootactv.bin of=/dev/hda bs=446 count=1"
  \item reboot.
\end{itemize}

Deinstallation:
\begin{itemize}
  \item boot Linux.
  \item restore the old MBR, e.g. \\
    \verb"dd if=/MBR of=/dev/hda bs=446 count=1" \\
    or \verb"FDISK /MBR" under MS-DOS.
\end{itemize}

If replacing the MBR appears undesirable and if a second Linux partition
exists (e.g. {\tt /usr}, {\bf not} a swap partition), {\sf BOOTACTV} can
be merged with
the partition table and stored as the ``boot sector'' of that partition.
Then, the partition can be marked active to be booted by the DOS-MBR.

Example:
\begin{verbatim}
# dd if=/dev/hda of=/dev/hda3 bs=512 count=1
# dd if=bootactv.bin of=/dev/hda3 bs=446 count=1
\end{verbatim}

Warning: whenever the disk is re-partitioned, the merged boot sector on that
``spare'' Linux partition has to be updated too.


\subsection{\LILO\ alone}

\boottwo{LILO \sep Linux \\
  \branch {\rm other OS}}

\LILO\ can also take over the entire boot procedure. If installed as the MBR,
\LILO\ is responsible for either booting Linux or any other OS. This approach
has the disadvantage, that the old MBR is overwritten and has to be restored
(either from a backup copy, with \verb"FDISK /MBR" on MS-DOS 5.0 or by
overwriting it with something like {\sf BOOTACTV}) if Linux should ever be
removed from the system.

You should verify that \LILO\ is able to boot your other operating system(s)
before relying on this method.

Installation:
\begin{itemize}
  \item boot Linux.
  \item make a backup copy of your MBR on a floppy disk, e.g. \\
    \verb"dd if=/dev/hda of=/fd/MBR bs=512 count=1"
  \item install \LILO\ with its boot sector as the MBR.
  \item reboot.
\end{itemize}

Deinstallation:
\begin{itemize}
  \item boot Linux.
  \item restore the old MBR, e.g. \\
    \verb"dd if=/fd/MBR of=/dev/hda bs=446 count=1"
\end{itemize}

If you've installed \LILO\ to be the master boot record, you have to
explicitly specify the boot sector (configuration variable {\tt boot=$\ldots$})
when updating the map. Otherwise, it
will try to use the boot sector of your current root partition, which
may even work, but will leave your system unbootable.


\subsection{Names}

The following names have been used to describe boot sectors or parts of
operating systems:

\begin{description}
  \item[\bf DOS-MBR] is the original MS-DOS MBR. It scans the partition
    table for a partition that is marked ``active'' and loads the boot
    sector of that partition. Programs like MS-DOS' {\sf FDISK}, Linux
    {\sf fdisk} or {\sf activate} (accompanies \LILO)
    can change the active marker in the partition table.
  \item[\bf MS-DOS] denotes the MS-DOS boot sector that loads the other parts
    of the system ({\tt IO.SYS}, etc.).
  \item[\bf COMMAND.COM] is the standard command interpreter of MS-DOS.
  \item[\bf BOOTLIN] is a program that loads a Linux kernel image from an
    MS-DOS partition into memory and executes it. It is usually invoked
    from {\tt CONFIG.SYS} and used in combination with a {\tt CONFIG.SYS}
    configuration switcher, like BOOT.SYS.\footnote{{\sf BOOTLIN} is
      available for anonymous FTP from \\
      {\tt nic.funet.fi:/pub/OS/Linux/tools/bootlin.zip} \\
      BOOT.SYS is available for anonymous FTP from \\
      {\tt sunsite.unc.edu:/pub/Linux/system/Linux-boot/boot142.zip}, \\
      {\tt nic.funet.fi:/pub/OS/Linux/tools/boot142.zip} or \\
      {\tt wuarchive.wustl.edu:/mirrors/msdos/sysutl/boot142.zip}}
  \item[\bf LILO] can either load a Linux kernel or the boot sector of any
    other operating system. It has a first stage boot sector that
    loads the remaining parts of \LILO\ from various locations.\footnote{%
      \LILO\ can be found in \\
      {\tt tsx-11.mit.edu:/pub/linux/packages/lilo/lilo.{\it n\/}.tar.gz} \\
      {\tt sunsite.unc.edu:/pub/Linux/system/Linux-boot/lilo/lilo.{\it
	n\/}.tar.gz}}
      {\tt nic.funet.fi:/pub/OS/Linux/tools/lilo.{\it n\/}.tar.gz}
  \item[\bf BOOTACTV] permits interactive selection of the partition from
    which the boot sector should be read. If no key is pressed within a
    given interval, the partition marked active is booted. {\sf BOOTACTV} is
    included in the {\sf pfdisk} package. There are also several similar
    programs, like PBOOT and OS-BS.\footnote{{\sf pfdisk} is available for
      anonymous FTP from \\
      {\tt sunsite.unc.edu:/pub/Linux/utils/disk-management/pfdisk.tar.Z} or \\
      {\tt nic.funet.fi:/pub/OS/Linux/tools/pfdisk.tar.Z} \\
      PBOOT can be found in \\
      {\tt nic.funet.fi:/pub/OS/Linux/tools/pboot.zip}}
\end{description}


\newpage
\section{Choosing the ``right'' boot concept}

Although \LILO\ can be installed in many different ways, the choice is
usually limited by the present setup and therefore,
typically only a small number of configurations which fit naturally
into an existing system remains.

The configuration file {\tt /etc/lilo/config} for the examples
could look like this:

\begin{verbatim}
compact
boot = /dev/hda2
image = /linux
image = /linux.backup
other = /dev/hda1
  table = /dev/hda
  label = msdos
\end{verbatim}

It installs a Linux kernel image ({\tt /linux}),
an alternate Linux kernel image ({\tt /linux.backup}) and
a chain loader to boot MS-DOS from {\tt /dev/hda1}.

In all examples, the names of the AT-type hard disk devices
({\tt /dev/hda$\ldots$}) are used. Everything applies to SCSI disks
({\tt /dev/sda$\ldots$}) too.


\subsection{One disk, Linux on a primary partition}

If at least one primary partition of the first hard disk is used as a
Linux file system ({\tt /}, {\tt /usr}, etc. but {\bf not} as a swap
partition), the \LILO\ boot sector should be stored on that partition
and it should be booted by the original master boot record or by a
program like {\sf BOOTACTV}.

$$
  \begin{tabular}{r|c|c|}
    \cline{2-3}
    & \multicolumn{2}{|l|}{MBR\hbox to 1.3in{\hfill\tt /dev/hda~}} \\
    \cline{3-3}
    & & MS-DOS\hfill\tt /dev/hda1 \\
    \cline{3-3}
    $\rightarrow$ & & Linux {\tt /}\hfill\tt /dev/hda2 \\
    \cline{2-3}
  \end{tabular}
$$

In this example, the {\tt boot} variable could be omitted, because
the boot sector is on the root partition.


\subsection{One disk, Linux on a logical partition}

If no primary partition is available for Linux, but at least one logical
partition of an extended partition on the first hard disk contains a
Linux file system, the \LILO\ boot sector should be stored in the partition
sector of the extended partition and it should be booted by the original
master boot record or by a program like {\sf BOOTACTV}.

$$
  \begin{tabular}{r|c|c|c|}
    \cline{2-4}
    & \multicolumn{3}{|l|}{MBR\hbox to 1.3in{\hfill\tt /dev/hda~}} \\
    \cline{3-4}
    & & \multicolumn{2}{|l|}{MS-DOS\hfill\tt /dev/hda1} \\
    \cline{3-4}
    $\rightarrow$ & & \multicolumn{2}{|l|}{Extended\hfill\tt /dev/hda2} \\
    \cline{4-4}
    & & & Linux\hfill\tt /dev/hda5 \\
    \cline{4-4}
    & & & $\ldots$\hfill\tt /dev/hda6 \\
    \cline{2-4}
  \end{tabular}
$$

Because many disk partitioning programs refuse to make an extended
partition (in our example {\tt /dev/hda2}) active, you might have to
use {\sf activate}, which comes with the \LILO\ distribution.


\subsection{Two disks, Linux (at least partially) on the first disk}

This case is equivalent to the configurations where only one disk
is in the system. The Linux boot sector resides on the first hard
disk and the second disk is used later.

Only the location of the boot sector matters -- everything
else ({\tt /etc/lilo/boot.b},
{\tt /etc/lilo/map}, the root file system, a swap partition, other
Linux file systems, etc.) can be located anywhere on the second disk.


\subsection{Two disks, Linux on the second disk, the first disk has an
  extended partition}

If there is no Linux partition on the first disk, but there is an
extended partition, the \LILO\ boot sector can be stored in the partition
sector of the extended partition and it should be booted by the original
master boot record or by a program like {\sf BOOTACTV}.

$$
  \begin{tabular}{r|c|c|c|c|c|c|}
    \multicolumn{1}{r}{}
    & \multicolumn{3}{c}{\bf First disk} &
      \multicolumn{1}{r}{\qquad}
      & \multicolumn{2}{c}{\bf Second disk} \\
    \cline{2-4}\cline{6-7}
    & \multicolumn{3}{|l|}{MBR\hbox to 1.3in{\hfill\tt /dev/hda~}} &
      & \multicolumn{2}{|l|}{MBR\hbox to 1.3in{\hfill\tt /dev/hdb~}} \\
    \cline{3-4}\cline{7-7}
    & & \multicolumn{2}{|l|}{MS-DOS\hfill\tt /dev/hda1} &
      & & Linux\hfill\tt /dev/hdb1 \\
    \cline{3-4}\cline{7-7}
    $\rightarrow$ & & \multicolumn{2}{|l|}{Extended\hfill\tt /dev/hda2} &
      & & $\ldots$\hfill\tt /dev/hdb2 \\
    \cline{4-4}
    & & & $\ldots$\hfill\tt /dev/hda5 & & & \\
    \cline{4-4}
    & & & $\ldots$\hfill\tt /dev/hda6 & & & \\
    \cline{2-4}\cline{6-7}
  \end{tabular}
$$

The program {\sf activate}, that accompanies \LILO, may have to be used to
set the active marker on an extended partition, because MS-DOS' {\sf FDISK}
and some older version of Linux {\sf fdisk} refuse to do that. (Which is
generally a good idea.)


\subsection{Two disks, Linux on the second disk, the first disk has no
  extended partition}

If there is neither a Linux partition nor an extended partition on the first
disk, where a \LILO\ boot sector could be stored, then there's only one place
left: the master boot record.

In this configuration, \LILO\ is responsible for booting all other operating
systems too.

$$
  \begin{tabular}{r|c|c|c|c|c|}
    \multicolumn{1}{r}{}
    & \multicolumn{2}{c}{\bf First disk} &
      \multicolumn{1}{r}{\qquad}
      & \multicolumn{2}{c}{\bf Second disk} \\
    \cline{2-3}\cline{5-6}
    $\rightarrow$ & \multicolumn{2}{|l|}{MBR\hbox to 1.3in{
      \hfill\tt /dev/hda~}} &
      & \multicolumn{2}{|l|}{MBR\hbox to 1.3in{\hfill\tt /dev/hdb~}} \\
    \cline{3-3}\cline{6-6}
    & & MS-DOS\hfill\tt /dev/hda1 &
      & & Linux\hfill\tt /dev/hdb1 \\
    \cline{3-3}\cline{6-6}
    & & $\ldots$\hfill\tt /dev/hda2 &
      & & $\ldots$\hfill\tt /dev/hdb2 \\
    \cline{2-3}\cline{5-6}
  \end{tabular}
$$

You should back up your old MBR before installing \LILO\ and verify that
\LILO\ is able to boot your other operating system(s) before relying on
this approach.

The line \verb"boot = /dev/hda2" in {\tt /etc/lilo/config} would have to be
changed to \verb"boot = /dev/hda" in this example.


\newpage
\section{The boot prompt}
\label{cmdopt}

Immediately after it's loaded, \LILO\ checks, whether one of the following
is happening:

\begin{itemize}
  \item any of the \key{Shift}, \key{Control} or \key{Alt} keys is being
    pressed.
  \item \key{CapsLock} or \key{ScrollLock} is set.
\end{itemize}

If this is the case, \LILO\ displays the \verb"boot:" prompt and waits for
the name of a boot image (i.e. Linux kernel or other operating system).
Otherwise, it boots the default boot image\footnote{%
The default boot image is either the first boot image or the image that
has been selected at the boot prompt.}
or -- if a
delay has been specified -- waits for one of the listed activities
until that amount of time has passed.

At the boot prompt, the name of the image to boot can be entered. Typing
errors can be corrected with \key{BackSpace}, \key{Delete},
\key{Ctrl U} and \key{Ctrl X}. A list of known images can be obtained by
pressing \key{?} (on the US keyboard) or \key{Tab}.

If \key{Enter} is pressed and no file name has been entered, the default
image is booted.

\LILO\ is also able to pass command-line options to the kernel.
Command-line options are words that follow the name of the boot
image and that are separated by spaces. Currently, the kernel
recognizes the options {\tt root={\it device\/}}, {\tt ro}, {\tt rw} and
{\tt no387},
and all current {\sf init} programs also recognize the option {\tt single}.
The option {\tt vga} is processed by the boot loader itself.

{\tt single} boots the system in single-user mode. This bypasses all
system initialization procedures and directly starts a root shell on the
console. Multi-user mode can be entered by exiting the single-user shell
or by rebooting.

{\tt root={\it device\/}} changes the root device. This overrides
settings that may have been made in the boot image and on the
\LILO\ command line. {\it device\/} is either the hexadecimal device number%
\footnote{%
This is a list of device numbers of some frequently used devices: \\
\begin{tabular}{lllllll}
\qquad
& {\tt /dev/fd0} & 200\qquad & \tt /dev/hda1 & 301\qquad & /dev/sda1 & 801 \\
& {\tt /dev/fd1} & 201 & \tt /dev/hda2 & 302 & /dev/sda2 & 802 \\
& \multicolumn{2}{c}{$\cdots$} & \multicolumn{2}{c}{$\cdots$} &
\multicolumn{2}{c}{$\cdots$} \\
& & & \tt /dev/hdb1 & 341 & /dev/sdb1 & 811 \\
& & & \tt /dev/hdb2 & 342 & /dev/sdb2 & 812 \\
& \multicolumn{2}{c}{} & \multicolumn{2}{c}{$\cdots$} &
\multicolumn{2}{c}{$\cdots$} \\
\end{tabular}}
or the full path name of the device, e.g. \verb"/dev/hda3".%
\footnote{The device names are hard-coded in the kernel. Therefore, only
the ``standard'' names are supported and some less common devices may not
be recognized. In those cases, only numbers can be used.}

{\tt ro} instructs the kernel to mount the root file system read-only.
{\tt rw} mounts it read-write. If neither {\tt ro} nor {\tt rw} is
specified, the setting from the boot image is used. {\tt no387}
disables using the hardware FPU.

Depending on the kernel configuration, also some special configuration
options for non-standard hardware may be recognized. Please consult the
corresponding FAQs and HOWTOs for details.

{\tt vga={\it mode\/}} alters the VGA mode set at startup. The values
{\tt normal}, {\tt extended}, {\tt ask} or a decimal number are
recognized. (See also page \pageref{vga}.)

Other options of the type {\it variable\/{\tt =}value\/} than {\tt root}
and {\tt vga}
cause the respective variables to be set in the environment passed to
{\sf init}. The case of the variable name is preserved. (I.e. it's not
automatically converted to upper case.)

Example:
\begin{verbatim}
boot: linux single root=200
\end{verbatim}

\LILO\ always passes the string ``{\tt BOOT\_IMAGE=\it name\/}'' to the
kernel, where {\it name\/} is the name by which the kernel is identified
(e.g. the label). This variable can be used in {\tt /etc/rc} to select
different behaviour, depending on the kernel.

When booting automatically, the word ``{\tt auto}'' is also passed on
the command line. This can be used by {\sf init} to suppress interactive
prompts in the boot phase.

The details of selecting the boot image are somewhat complicated. The
following tables illustrate them. First, if neither {\tt prompt} is
set nor a shift key is being pressed:

$$
\begin{tabular}{cc|cl}
  Externally & Command  & Auto- & Booted image \\
  provided   & line in  & matic & \\
  cmd. line  & map file & boot  & \\
  \hline
  No  & No  & Yes & Default image \\
  Yes & --- & Yes & Specified by external \\
      &     &     & command line \\
  No  & Yes & Yes & Specified by command line \\
      &     &     & in map file \\
\end{tabular}
$$

If {\tt prompt} is not set and a shift key is being pressed:
$$
\begin{tabular}{cccc|cl}
  Input   & Empty  & Extern. & Cmd.l.  & Auto- & Booted image \\
  timeout & cmd.l. & cmd.l.  & in map  & matic & \\
          &        &         & file    & boot  & \\
  \hline
  No  & No  & --- & --- & No  & Specified by the user \\
  No  & Yes & --- & --- & No  & Default image \\
  Yes & n/a & --- & --- & Yes & Default image \\
\end{tabular}
$$

Finally, if the configuration variable {\tt prompt} is set:
$$
\begin{tabular}{cccc|cl}
  Input   & Empty  & Extern. & Cmd.l.  & Auto- & Booted image \\
  timeout & cmd.l. & cmd.l.  & in map  & matic & \\
          &        &         & file    & boot  & \\
  \hline
  No  & No  & No  & No  & No  & Specified by the user \\
  No  & Yes & No  & No  & No  & Default image \\
  Yes & n/a & No  & No  & Yes & Default image \\
  n/a & n/a & Yes & --- & Yes & Specified by external \\
      &     &     &     &     & command line \\
  n/a & n/a & No  & Yes & Yes & Specified by command \\
      &     &     &     &     & line in map file \\
\end{tabular}
$$

The default image is typically the first image in the map file. However,
after an unsuccessful boot attempt, the respective image becomes the
default image.


\newpage
\section{Map installer}

The map installer program {\tt /etc/lilo/lilo} updates the boot sector
and creates the map file. If the map installer detects an error, it terminates
immediately and does not touch the boot sector and the map file.

Whenever the map installer updates a boot sector, the original boot
sector is copied
to {\tt /etc/lilo/boot.{\it number\/}}, where {\it number\/} is the
hexadecimal device number. If such a file already exists, no backup
copy is made. Similarly, a file {\tt /etc/lilo/part.{\it number\/}} is
created if \LILO\ modifies the partition table. (See page \pageref{fix-table}.)


\subsection{Command-line arguments}

The \LILO\ map installer accepts the following command-line options:

\begin{description}
  \item[\tt -C \it config\_file]~ \\
    Specifies the configuration file that is used by the map
    installer (see section \ref{config}). If {\tt -C} is omitted,
    {\tt /etc/lilo/config} is used.
  \item[\tt -I \it name {$[$} options {$]$}]~ \\
    Translates the specified label name to the path of the corresponding kernel
    image and prints that path on standard output. This can be used to rebuild
    files that depend on the kernel (e.g. the {\sf ps} database). The image
    name can be obtained from the environment variable {\tt BOOT\_IMAGE}. An
    error message is issued and a non-zero exit code is returned if no
    matching label name can be found. The existence of the image file is
    verified if the option character {\tt v} is added.
  \item[\tt -q]~ \\
    Lists the currently mapped files.
  \item[\tt -r \it root\_directory]~ \\
    Chroots to the specified directory before doing anything else. This is
    useful when running the map installer while the normal root file system
    is mounted somewhere else, e.g. when recovering from an installation
    failure with an install disk. The {\tt -r} option is implied if
    the environment variable {\tt ROOT} is set.\footnote{I.e. if your root
      partition is mounted on {\tt /mnt}, you can update the map by simply
      running {\tt ROOT=/mnt /mnt/etc/lilo/lilo}.}
    The current directory is changed to the new root directory, so using
    relative paths may not work.
  \item[\tt -R \it word {$\ldots$}]~ \\
    Stores the specified words in the map file. The boot loader uses those
    words as the default command line when booting the next time. That command
    line is removed from the map file by the boot loader by overwriting the
    sector immediately after reading it. The first word has
    to be the name of a boot image. If {\tt -R} is not followed by any words,
    the current default command line in the map file is erased.\footnote{%
      {\tt -R} is typically used in reboot scripts, e.g. \\
\tt \#!/bin/sh \\
if /etc/lilo/lilo -R "\$*"; then \\
\hbox to 0pt{}~~~~echo $\vert$ shutdown -r now \\
fi}
    An error message is issued and a non-zero exit code is returned if the
    command line is not accepted.
  \item[\tt -t]~ \\
    Test only. This performs the entire installation procedure except
    replacing the map file and writing the modified boot sector. This
    can be used in conjunction with the {\tt -v} option to verify that
    \LILO\ will use sane values.
  \item[\tt -u {$[$} \it device\_name {$]$}]~ \\
    Restores the backup copy of the specified boot sector. If no device is
    specified, the value of the \verb"boot" variable is used. If this one
    is also unavailable, \LILO\ uses the current root device. The name of
    the backup copy is derived from the device name. The \verb"-s" option
    or the \verb"backup" variable can be used to override this. \LILO
    validates the backup copy by checking a time stamp.
  \item[\tt -U {$[$} \it device\_name {$]$}]~ \\
    Like \verb"-u", but does not check the time stamp.
  \item[\tt -V]~ \\
    Print the version number and exit.
\end{description}

There are also many command-line options that correspond to configuration
variables. See section \ref{cfgvar} for a description.

$$
\begin{tabular}{l|l}
  Command-line option		& Configuration variable \\
  \hline
  \tt -b \it boot\_device	& \tt boot=\it boot\_device \\
  \tt -c			& \tt compact \\
  \tt -d \it tsecs		& \tt delay=\it tsecs \\
  \tt -i \it boot\_sector	& \tt install=\it boot\_sector \\
  \tt -f \it disktab\_file	& \tt disktab=\it disktab\_file \\
  \tt -l			& \tt linear \\
  \tt -m \it map\_file		& \tt map=\it map\_file \\
  \tt -P fix			& \tt fix-table \\
  \tt -P ignore			& \tt ignore-table \\
  \tt -s \it backup\_file	& \tt backup=\it backup\_file \\
  \tt -S \it backup\_file	& \tt force-backup=\it backup\_file \\
  \tt -v $\ldots$		& \tt verbose=\it level \\
\end{tabular}
$$

The image files can reside on any media that is accessible at boot time.
There's no need to put them on the root device, although this certainly
doesn't hurt.


\subsection{Configuration}
\label{config}

The configuration information is stored in the file {\tt /etc/lilo/config}
and consists of variable assignments. The following syntax rules apply:

\begin{itemize}
  \item flag variables consist of a single word and are followed by
    whitespace or the end of the file.
  \item string variables consist of the variable name, optional whitespace,
    an equal sign, optional whitespace, the value and required whitespace,
    or the end of the file.
  \item a non-empty sequence of blanks, tabs, newlines and comments counts
    as whitespace.
  \item variable names are case-insensitive. Values are usually case-sensitive,
    but there are a few exceptions. (See below.)
  \item tabs and newlines are special characters and may not be part of a
    variable name or a value. The use of other control characters and
    non-ASCII characters is discouraged.
  \item blanks and equal signs may only be part of a variable name or a
    value if they are escaped by a backslash or if the value is embedded in
    double quotes. An equal sign may not be the only character in a name or
    value.
  \item an escaped tab is converted to an escaped blank. An escaped newline
    is removed from the input stream. An escaped backslash (i.e. two
    backslashes) is converted to a backslash. Inside quoted strings, only
    double quotes can be escaped.
  \item comments begin with a number sign and end with the next newline.
    All characters (including backslashes) until the newline are ignored.
\end{itemize}

{\tt /etc/lilo/config} begins with a possibly empty options section. Most
options can also be set from the command line, but storing permanent
options in the configuration file is more convenient. The following
options are recognized:

\label{cfgvar}
\begin{description}
  \item[\tt boot=\it boot\_device\/] Sets the name of the device (e.g.
    a hard disk partition) that contains
    the boot sector. If {\tt boot} is omitted, the boot sector is read from
    (and possibly written to) the device that is currently mounted as root.
  \item[\tt compact] Tries to merge read requests for adjacent sectors into
    a single read request. This drastically reduces load time and keeps the
    map smaller. Using {\tt compact} is especially recommended when booting
    from a floppy disk.
  \item[\tt delay=\it tsecs\/] Specifies the number of tenths of a second
    \LILO\ should wait before booting the first image. This is useful on
    systems that immediately boot from the hard disk after enabling the
    keyboard. \LILO\ doesn't wait if {\tt delay} is omitted.
  \item[\tt linear] Generate linear sector addresses instead of
    sector/head/cylinder addresses. Linear addresses are translated at run
    time and do not depend on disk geometry. Note that boot disks, where
    {\tt linear} is used, may not be portable.
  \item[\tt install=\it boot\_sector\/] Install the specified file as the new
    boot sector. If {\tt install} is omitted, {\tt /etc/lilo/boot.b} is used
    as the default.
  \item[\tt disktab=\it disktab\_file\/] Specifies the name of the disk
    parameter table (see section \ref{disktab}). The map installer looks for
    {\tt /etc/lilo/disktab} if {\tt disktab} is omitted.
  \item[\tt map=\it map\_file\/] Specifies the location of the map file.
    If {\tt map} is omitted, a file {\tt /etc/lilo/map} is used.
  \item[\tt message=\it message\_file\/] specifies a file containing a message
    that is displayed before the boot prompt. No message is displayed
    when waiting for a shifting key after printing ``LILO ''. The {\bf FF}
    character (\hbox{\key{Ctrl L}}) clears the local screen. The size of the
    message file is limited to 65535 bytes. The map file has to be rebuilt
    if the message file is changed or moved.
  \item[\tt verbose=\it level\/] Turns on lots of progress reporting.
    Higher numbers give more verbose output. If {\tt -v} is additionally
    specified on the command line, {\it level} is increased accordingly.
  \item[\tt backup=\it backup\_file\/] Copy the original boot sector to
    {\it backup\_file\/} (which may also be a device, e.g. {\tt /dev/null})
    instead of {\tt /etc/lilo/boot.{\it number}}
  \item[\tt force-backup=\it backup\_file\/] Like {\tt backup}, but overwrite
    an old backup copy if it exists. {\tt backup=\it backup\_file} is ignored
    if {\tt force-backup} appears in the same configuration file.
  \item[\tt prompt] forces entering the boot prompt without expecting any
    prior key-presses. Unattended reboots are impossible if {\tt prompt} is
    set and {\tt timeout} isn't.
  \item[\tt timeout=\it tsecs\/] sets a timeout (in tenths of a second) for
    keyboard input. If no key is pressed for the specified time, the first
    image is automatically booted. Similarly, password input is aborted if
    the user is idle for too long. The default timeout is infinite.
  \item[\tt serial=\it parameters\/] enables control from a serial line. The
    specified serial port is initialized and \LILO\ is accepting input from
    it and from the PC's keyboard. Sending a break on the serial line
    corresponds to pressing a shift key on the console in order to get
    \LILO's attention. All boot images should be password-protected if the
    serial access is less secure than access to the console, e.g. if the
    line is connected to a modem. The parameter string has the following
    syntax: \\
    {\it port\/\tt,\it bps\/\,parity\/\,bits} \\
    The components {\it bps}, {\it parity\/} and {\it bits\/} can be
    omitted. If a component is omitted, all following components have to
    be omitted too. Additionally, the comma has to be omitted if only the
    port number is specified.
    \begin{description}
      \item[\it port\/] the number of the serial port, zero-based. 0
	corresponds to {\tt COM1} alias {\tt /dev/ttyS0}, etc. All four
	ports can be used (if present).
      \item[\it 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.
      \item[\it parity\/] the parity used on the serial line. \LILO\ ignores
	input parity and strips the 8th bit. The following (upper or lower
	case) characters are used to describe the parity: {\tt n} for no
	parity, {\tt e} for even parity and {\tt o} for odd parity.
      \item[\it 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''.
    \end{description}
    If {\tt serial} is set, the value of {\tt delay} is automatically raised
    to 20. Example: \verb"serial=0,2400n8" initializes {\tt COM1} with the
    default parameters.
  \item[\tt ignore-table] tells LILO to ignore corrupt partition tables.
  \item[\tt fix-table]\label{fix-table} allows \LILO\ to adjust 3D addresses
    in partition
    tables. Each partition entry contains a 3D (sector/head/cylinder) and a
    linear address of the first and the last sector of the partition. If a
    partition is not track-aligned and if certain other operating systems
    (e.g. PC/MS-DOS or OS/2) are using the same disk, they may change the 3D
    address. \LILO\ can store its boot sector only on partitions where both
    address types correspond. \LILO\ re-adjusts incorrect 3D start addresses
    if {\tt fix-table} is set. \\
    {\bf WARNING:} This does not guarantee that other operating systems may not
    attempt to reset the address later. It is also possible that this change
    has other, unexpected side-effects. The correct fix is to re-partition
    the drive with a program that does align partitions to tracks.
  \item[\tt password=\it password\/] sets a password for all images.
    (See below.)
  \item[\tt restricted] relaxes the password protection. (See below.)
  \item[\tt optional] makes all images optional. (See below.)
\end{description}

Additionally, the kernel configuration parameters {\tt append}, {\tt ramdisk},
{\tt read-only}, {\tt read-write}, {\tt root} and {\tt 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. See below for a
description.

If the option {\tt -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 {\tt /etc/lilo/config} and they are registered in
the boot sector.

Each
image description begins with a special variable and is followed by optional
variables. The following variables can be used for all image descriptions
that describe a Linux kernel:

\begin{description}
  \item[\tt append=\it string\/] Appends the options specified in
    {\it string\/} to the parameter line passed to the kernel. This is
    typically used to specify parameters of hardware that can't be entirely
    auto-detected, e.g.\\
    \verb'append = "hd=64,32,202"'
  \item[\tt literal=\it string\/] Like {\tt append}, but removes all other
    options (e.g. setting of the root device). Because vital options can be
    removed unintentionally with {\tt literal}, this option cannot be set in
    the global options section.
  \item[\tt ramdisk=\it size\/] specifies the size of the optional RAM disk.
    A value of zero indicates that no RAM disk should be created. If this
    variable is omitted, the RAM disk size that is configured into the boot
    image is used.
  \item[\tt read-only] specifies that the root file system should be
    mounted read-only. Typically, the system startup procedure re-mounts
    the root file system read-write later (e.g. after fsck'ing it).
  \item[\tt read-write] specifies that the root file system should be
    mounted read-write.
  \item[\tt root=\it root\_device\/] specifies the device that should be
    mounted as root. If the special name {\tt current} is used, the root
    device is set to the device on which the root file system is currently
    mounted. If the root has been changed with {\tt -r}, the respective
    device is used. If the variable {\tt root} is omitted, the root device
    setting that is contained in the kernel image is used. It can be changed
    with the {\sf rdev} program.
  \item[\tt vga=\it mode\/]\label{vga} specifies the VGA text mode that
    should be selected when booting. The following values are recognized
    (case is ignored):
    \begin{description}
      \item[\tt normal] select normal 80x25 text mode.
      \item[\tt extended] select 80x50 text mode. The word \verb"extended"
	can be abbreviated to \verb"ext".
      \item[\tt ask] stop and ask for user input (at boot time).
      \item[\it number\/] use the corresponding text mode. A list of available
	modes can be obtained by booting with {\tt vga=ask} and pressing
	\key{Enter}.
    \end{description}
    If this variable is omitted, the VGA mode setting that is contained in the
    kernel image is used. {\sf rdev} supports manipulation
    of the VGA text mode setting in the kernel image.
\end{description}

If one of {\tt ramdisk}, {\tt read-only}, {\tt read-write}, {\tt root},
or {\tt vga} is omitted in the configuration file and the
corresponding value in the kernel image is changed, \LILO\ will use the new
value.

It is perfectly valid to use different settings for the same
image, because \LILO\ stores them in the image descriptors and not in the
images themselves.

Example:
\begin{verbatim}
image = /linux
  label = lin-hd
  root = /dev/hda2
image = /linux
  label = lin-fd
  root = /dev/fd0
\end{verbatim}

\LILO\ uses the main file name (without its path) of each image specification
to identify that image. A different name can be used by setting the variable
{\tt label} (see the example above). A different name for the same entry
can be used by specifying the {\tt alias=\it name} option.

Images are protected by a password if the variable {\tt password} is set.
If the variable {\tt restricted} is set in addition to {\tt password},
a password is only required to boot the respective image if parameters
are specified on the command line (e.g. \verb"single").
{\tt password} and {\tt restricted} can also be set in the options section
to be the default password and password protection mode for all images.

If an image section contains the variable {\tt optional} (or if that variable
is set in the options section), the respective image is omitted if its main
file is not available at map creation time. This is useful to specify test
kernels that are not always present.


\subsection{Boot image types}

\LILO\ can boot the following types of images:
\begin{itemize}
  \item kernel images from a file.
  \item kernel images from a block device. (I.e. a floppy disk.)
  \item the boot sector of some other operating system.
\end{itemize}

The image type is determined by the name of the initial
variable of the configuration section.

In the configuration sections of all boot images, the following variables
are recognized: {\tt alias}, {\tt label}, {\tt optional}, {\tt password}
and {\tt restricted}.

In the configuration sections of all kernels (i.e. every boot image type
except ``other operating system''), the following variables are recognized:
{\tt ramdisk}, {\tt read-only}, {\tt read-write}, {\tt root} and {\tt vga}.


\subsubsection{Booting kernel images from a file}

The image is specified as follows: {\tt image=\it name}

Example:
\begin{verbatim}
image = /linux
\end{verbatim}


\subsubsection{Booting kernel images from a device}

The range of sectors
that should be mapped, has to be specified. Either a range
({\it start\/\tt -\it end\/}) or a start and a distance
({\it start\/\tt +\it number\/}) have to be specified. {\it start\/}
and {\it end\/} are zero based. If only
the start is specified, only that sector is mapped.

The image is specified as follows: {\tt image=\it device\_name}\quad
Additionally, the {\tt range} variable must be set.

Example:
\begin{verbatim}
image = /dev/fd0
  range = 1+512
\end{verbatim}


\subsubsection{Booting a foreign operating system}

\LILO\ can even boot other operating systems, i.e. MS-DOS.
To boot an other operating
system, the name of a loader program, the device that contains the boot
sector and the device that contains the partition table have to be
specified.

The boot sector is merged with the partition table and stored in the map file.

Currently, the loaders {\tt chain.b}, {\tt os2\_d.b} and {\tt any\_d.b} exist.
{\tt chain.b} simply starts the specified boot sector.\footnote{The boot
sector is loaded by \LILO's secondary boot loader before control is passed
to the code of {\tt chain.b}.} {\tt os2\_d.b} can boot OS/2 from the second
hard disk. {\tt any\_d.b} installs a resident driver that swaps the first
and the second hard disk drive. It can boot any operating system from the
second hard disk, if it uses only the BIOS. This is known to work for
PC/MS-DOS.

The image is specified as follows: {\tt other=\it device\_name}

The following additional variables are recognized: {\tt loader}, {\tt table}
and {\tt unsafe}.

\begin{description}
  \item[\tt loader=\it chain\_loader\/] specifies the chain loader that should
    be used. If it is omitted, {\tt /etc/lilo/chain.b} is used.
  \item[\tt table=\it device\/] specifies the device that contains the partition
    table. \LILO\ does not pass partition information to the booted operating
    system if this variable is omitted. (Some operating systems have other
    means to determine from which partition they have been booted. E.g. MS-DOS
    usually stores the geometry of the boot disk or partition in its boot
    sector.)
  \item[\tt unsafe] do not access the boot sector at map creation time. This
    disables some sanity checks. If the boot sector is on a fixed-format
    floppy disk device, using {\tt unsafe} avoids the need to put a readable
    disk into the drive when running the map installer. {\tt unsafe} and
    {\tt table} are mutually incompatible.
\end{description}

Example:
\begin{verbatim}
other = /dev/hda2
  label = os2
  table = /dev/hda
\end{verbatim}


\subsection{Disk parameter table}
\label{disktab}

For floppies, IDE disks (or MFM, RLL, ESDI, etc.) and most SCSI disks,
\LILO\ can obtain the
disk geometry information from the kernel. Unfortunately, this is not
possible with all SCSI adapters.\footnote{The 0.99pl7 kernel provides
geometry information for Adaptec AHA-1542 and AHA-1740, Future Domain
TMC-1660, TMC-1670 and TMC-1680, UltraStor 14F and WD-7000 adapters.} In
such cases, \LILO\ reports either the error \\
{\tt geo\_query\_dev HDIO\_GETGEO (dev 0x{\it number})} \\
or \\
{\tt Device 0x{\it number\/}: Got bad geometry {\it sec\/}/{\it hd\/}/%
{\it cyl}}

The file {\tt /etc/lilo/disktab} is used to describe
such disks. For each device ({\tt /dev/sda} $\rightarrow$ 0x800,
{\tt /dev/sda1} $\rightarrow$ 0x801, etc.),
the BIOS code and the disk geometry have to be specified, e.g.

\begin{verbatim}
# /etc/lilo/disktab  -  LILO disk parameter table
#
# This table contains disk parameters for SCSI disks and non-
# standard parameters of IDE disks. Parameters in disktab
# _always_ override auto-detected disk parameters.

# Dev.  BIOS    Secs/   Heads/  Cylin-  Part.
# num.  code    track   cylin.  ders    offset
#                                      (optional)

0x800   0x80    32      64      631     0       # /dev/sda
0x801   0x80    32      64      631     32      # /dev/sda1
0x802   0x80    32      64      631     204800  # /dev/sda2
\end{verbatim}

Those parameters are just a random example from my system. However, many
SCSI controllers
re-map the drives to 32 sectors and 64 heads. The number of cylinders
does not have to be exact, but it shouldn't be lower than the number of
effectively available cylinders.

Note that the device number and the BIOS code have to be specified as
hexadecimal numbers with the ``0x'' prefix.

The disk geometry parameters can be obtained by booting MS-DOS and
running the program {\tt DPARAM.COM} with the hexadecimal BIOS code of
the drive as its argument, e.g. \verb"dparam 0x80" for the first hard
disk. It displays the number of sectors per
track, the number of heads per cylinder and the number of cylinders.
All three numbers are one-based.

The partition offset is only necessary when using devices for which the
kernel does not provide that information, e.g. CD-ROMs. The partition
offset is counted in sectors and is zero-based.

Because many SCSI controllers don't support more than 1 GB when using
the BIOS interface, \LILO\ can't access files that are located beyond the
1 GB limit of large SCSI disks on such controllers and reports errors in
these cases.


\newpage
\section{Installation and updates}

{\bf IMPORTANT:} The current version of \LILO\ supports two different directory
hierarchies: the old hierarchy, where everything lives in {\tt /etc/lilo} and a
new hierarchy with files in {\tt /sbin}, {\tt /etc} and {\tt /boot}. Depending
on which hierarchy you want to use, the respective {\tt QuickInst} and
{\tt Makefile} files have to be chosen. See {\tt INCOMPAT} for details.


\subsection{Compatibility}

The kernel header files have to be in
{\tt /usr/include/linux} and the kernel usually has to be configured by
running {\tt make config} before \LILO\ can be compiled.

{\tt /bin/sh} has to be a real bourne shell. {\sf bash} is sufficiently
compatible, but some {\sf ksh} clones may cause problems.

Using command-line options that are handled by {\sf init} usually requires
a comparably new version of {\sf init}. All currently available {\sf init}
packages typically support new features of \LILO\ in the respective next
release.

A file named {\tt INCOMPAT} is included in the distribution. It describes
incompatibilities to older versions of \LILO\ and may also contain further
compatibility notes.


\subsection{Quick installation}
\label{quickinst}
If you want to install \LILO\ on your hard disk and if you don't want
to use all its features, you can use the quick installation script.
Read {\tt QuickInst.old} or {\tt QuickInst.new} for details.

{\sf QuickInst} can only be used for first-time installations or to
entirely replace an existing installation, {\bf not}
to update or modify an existing installation of \LILO. Be sure you've
extracted \LILO\ into a directory that doesn't contain any files of
other \LILO\ installations.


\subsection{Normal first-time installation}
\label{install}

First, you have to install the \LILO\ files:

\begin{itemize}
  \item extract all files from {\tt lilo.{\it version}.tar.gz} in a new
    directory.\footnote{%
Don't use {\tt /etc/lilo} for the \LILO\ source. Standard installation
procedures fail if the source is in the same directory as the production
binaries.}
  \item configure the {\tt Makefile} (see section \ref{cfgmf})
  \item run\quad{\tt make -f Makefile.old}\quad to compile and assemble all
    parts if you want to use the old directory structure, or
    \quad{\tt make -f Makefile.new}\quad if you prefer the new structure.
  \item run\quad{\tt make -f Makefile.old install}\quad or \quad
    {\tt make -f Makefile.new install}\quad to copy all \LILO\ files to
     {\tt /etc/lilo} (or to the new directories).
     {\tt /etc/lilo} should now contain the following files: {\tt any\_d.b},
     {\tt boot.b}, {\tt chain.b}, {\tt disktab}, {\tt lilo} and
     {\tt os2\_d.b}.
\end{itemize}

If you want to use \LILO\ on a SCSI disk, you might have to determine the
parameters of your SCSI disk(s) and put them into the file
{\tt /etc/lilo/disktab}. See section \ref{disktab} for details.
If you're using a disktab file, the next step is to test \LILO\ with the boot
sector on a floppy disk:

\begin{itemize}
  \item insert a blank (but low-level formatted) floppy disk into
    {\tt /dev/fd0}.
  \item cd to {\tt /etc/lilo}
  \item run {\tt echo image={\it kernel\_image}}\verb" |"\\
    {\tt ./lilo -C - -b /dev/fd0 -v -v -v}%
\footnote{If you've already installed \LILO\ on your system, you might not want
  to overwrite your old map file.
  Use the {\tt -m} option to specify an alternate map file name.}
  \item reboot. \LILO\ should now load its boot loaders from the floppy disk
    and then continue loading the kernel from the hard disk.
\end{itemize}

Now, your have to decide, which boot concept you want to use. Let's assume
you have a Linux partition on {\tt /dev/hda2} and you want to install your
\LILO\ boot sector there. The DOS-MBR loads the \LILO\ boot sector.

\begin{itemize}
  \item Get a working boot disk. Verify that you can boot
    with this setup and that you can mount your Linux partition(s) with it.
  \item If the boot sector you want to overwrite with \LILO\ is of any value
    (e.g. it's the MBR or if it contains a boot loader, you might want to use
    if you encounter problems with \LILO), you should mount your boot disk
    and make a backup copy of your boot sector to a file on that floppy,
    e.g. \verb"dd if=/dev/hda of=/fd/boot_sector bs=512 count=1"
  \item Link {\tt /etc/lilo/install} to {\tt lilo} (for backwards
    compatibility), e.g. \\
    \verb"cd /etc/lilo; ln -s lilo install" \\
  \item Create the configuration file {\tt /etc/lilo/config}, e.g. \\
{\it global settings} \\
\verb"  "{\it image specifications} \\
\verb"  "$\ldots$ \\
    Be sure to use absolute paths for all files. Relative paths may cause
    unexpected behaviour when using the {\tt -r} option.
  \item Now, you can check what \LILO\ would do if you were about to install
    it on your hard disk: \\
\verb"/etc/lilo/lilo -v -v -v -t"
  \item If you need some additional boot utility (i.e. {\sf BOOTACTV}), you
    should install that now.
  \item Run {\tt /etc/lilo/lilo} to install \LILO\ on your hard disk.
  \item If you have to change the active partition, use {\sf fdisk} or
    {\sf activate} to do that.
  \item Reboot.
\end{itemize}


\subsection{\LILO\ update}

When updating to a new version of \LILO, the initial steps are the same as
for a first time installation: extract all files, configure the {\tt Makefile},
run {\tt make} to build
the executables and run {\tt make install} to move the files to
{\tt /etc/lilo}.

The old versions of {\tt boot.b}, {\tt chain.b}, etc. are automatically
renamed to {\tt boot.old}, {\tt chain.old}, etc.. This is done to ensure
that you can boot even if the installation procedure does not finish.
{\tt boot.old}, {\tt chain.old}, etc. can be deleted after the map file
is rebuilt.

Because the locations of {\tt boot.b}, {\tt chain.b}, etc. have changed
and because the map file format may be different too, you have to update
the boot sector and the map file. Run {\tt /etc/lilo/lilo} to do this.


\subsection{Kernel update}

Whenever any of the kernel files that are accessed by \LILO\ is moved or
overwritten, the map has to be re-built.\footnote{It is advisable to
keep a second, stable, kernel image that can be booted if you forget
to update the map after a change to your usual kernel image.} Run
{\tt /etc/lilo/lilo} to do this.

The kernel has a make target ``zlilo'' that copies the kernel
to {\tt /vmlinuz} and runs {\tt /etc/lilo/install}.


\subsection{\LILO\ de-installation}

In order to stop \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 {\bf after} removing the boot sector, if desired.%
\footnote{Backup copies of old boot sectors may be needed when removing
the boot sector. They are stored in {\tt /etc/lilo}.}

LILO 0.14 (and newer) can be de-installed with \verb"lilo -u". If LILO 0.14
or newer is currently installed, but the first version of LILO installed was
older than 0.14, \verb"lilo -U" may work. When using \verb"-U", the warning
at the end of this section applies.

If \LILO's boot sector has been installed on a primary partition and is
booted by the ``standard'' MBR or some partition switcher program, it can be
disabled by making a different partition active. MS-DOS' FDISK, Linux
{\sf fdisk} or \LILO's {\sf activate} can do that.

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' ``standard'' MBR.
When using MS-DOS 5.0 or above, the MS-DOS MBR can be restored with
\verb"FDISK /MBR". This only alters the boot loader code, not the
partition table.

\LILO\ automatically makes backup copies when it overwrites boot sectors.
They are named {\tt /etc/lilo/boot.\it nnnn\/}, with {\it nnnn\/}
corresponding to the device number, e.g. {\tt 0300} is {\tt /dev/hda},
{\tt 0800} is {\tt /dev/sda}, etc. Those backups can be used to restore
the old MBR if no easier method is available. The commands are \\
{\tt dd if=/etc/lilo/boot.0300 of=/dev/hda bs=446 count=1} or \\
{\tt dd if=/etc/lilo/boot.0800 of=/dev/sda bs=446 count=1} \\
respectively.

{\bf WARNING:} Some Linux distributions install {\tt boot.\it nnnn\/} files
from the system where the distribution was created in {\tt /etc/lilo}. Using
those files may yield unpredictable results. Therefore, the file creation
date should be carefully checked.


\subsection{Installation of other operating systems}

Some other operating systems (e.g. MS-DOS 6.0) appear to modify the MBR in
their install procedures. It is therefore possible that \LILO\ will stop
to work after such an installation and Linux has to be booted from floppy
disk. The original state can be restored by either re-running
{\tt /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 {\tt /etc/lilo/lilo} has to be re-run) in order to boot
it.


\subsection{Build-time configuration}
\label{cfgmf}

Certain build-time parameters can be configured.
They can either be edited in the top-level {\tt Makefile} or they can be
stored in a file {\tt /etc/lilo/config.defines}. Settings in the {\tt Makefile}
are ignored if that file exists.

The following items can be configured:
\begin{description}
  \item[\tt IGNORECASE] Makes image name matching case-insensitive, i.e.
    ``linux'' and ``Linux'' are identical. This option is enabled by
    default. Note that password matching is always case-sensitive.
  \item[\tt NO1STDIAG] Do not generate diagnostics on read errors in the
    first stage boot loader. This avoids possibly irritating error codes
    if the disk controller has transient read problems. This option is
    disabled by default.
  \item[\tt NOINSTDEF] If the option {\tt install} is omitted, don't install
    a new boot sector, but try to modify the old boot sector instead. This
    option is disabled by default.
  \item[\tt ONE\_SHOT] Disables the command-line timeout (configuration
    variable {\tt TIMEOUT}) if any key is pressed. This way, very short
    timeouts can be used if {\tt PROMPT} is set. {\tt ONE\_SHOT} is disabled
    by default.
  \item[\tt READONLY] Disallows overwriting the default command line sector
    of the map file. This way, command lines set with {\tt -R} stay in effect
    until they are explicitly removed. This option is disabled by default.
\end{description}

{\tt /etc/lilo/config.defines} should be used if one wishes to make
permanent configuration changes. The usual installation procedures don't
touch that file. Example:

\begin{verbatim}
-DIGNORECASE -DONE_SHOT
\end{verbatim}


\newpage
\section{Troubleshooting}

All parts of \LILO\ display some messages that can be used to diagnose
problems. 


\subsection{Map installer errors}

Most messages of the map installer ({\tt /etc/lilo/lilo}) should be
self-explanatory. Some messages that indicate common errors are
listed below:

\begin{description}
  \item[\tt Can't put the boot sector on logical partition \it number]~\\
    An attempt has been made to put \LILO's boot sector on the current
    root file system partition which is on a logical partition. This usually
    doesn't have the desired effect, because common MBRs can only boot
    primary partitions. This check can be bypassed by explicitly
    specifying the boot partition with the {\tt -b} option or by setting
    the configuration variable {\tt boot}.
  \item[\tt Device 0x{\it number\/}: Got bad geometry {\it sec\/}/{\it hd\/}/%
{\it cyl}]~\\
    The device driver for your SCSI controller does not support geometry
    detection. You have to use an {\tt /etc/lilo/disktab} file.
  \item[\tt Device 0x{\it number\/}: Invalid partition table, entry %
    {\it number}]~\\
    The 3D and linear addresses of the first sector of the specified partition
    don't correspond. This is typically caused by partitioning a disk with
    a program that doesn't align partitions to tracks and using PC/MS-DOS
    or OS/2 later on that disk. \LILO\ can attempt to correct the problem,
    see page \pageref{fix-table}.
  \item[\tt First sector of {\it device} doesn't have a valid boot signature]%
    ~\\
    The first sector of the specified device does not appear to be a valid
    boot sector. You might have confused the device name.\footnote{Because
    different partition programs may display the partitions in a different
    order, it is possible that what you think is your first partition isn't
    {\tt /dev/hda1}, etc. A good method to verify the content of a partition
    is to try to mount it.}
  \item[\tt geo\_comp\_addr: Cylinder number is too big ({\it number} $>$
   1023)]~\\
    A file is located beyond the 1024th cylinder of a hard disk. \LILO\ can't
    access such files, because the BIOS limits cylinder numbers to the range
    0$\ldots$1023. Try moving the file to a different place, preferably a
    partition that is entirely within the first 1024 cylinders of the disk.
  \item[\tt Hole found in map file ({\it location\/})]~\\
    The map installer is
    confused about the disk organization. Please report this error.
  \item[\it item\/ \tt doesn't have a valid LILO signature]~\\
    The specified
    item has been located, but is not part of \LILO. If {\it item} is the
    first boot sector, you've
    probably forgotten to specify the {\tt -i} option or the {\tt install}
    variable to install the \LILO\ boot sector.
  \item[\it item \tt has an invalid stage code (\it number\/\tt)]~\\ The
    specified item has probably been corrupted. Try re-building
    \LILO.
  \item[\it item \tt is version {\it number}. Expecting version {\it number}.]%
    ~\\
    The specified entity is either too old or too new. Make sure all parts
    of \LILO\ (map installer, boot loaders and chain loaders) are from the
    same distribution. If {\it item} is the first boot sector, you have to
    run the map installer with the {\tt -i} option to update it.\footnote{%
    The expected version number may be different from the version number of the
    \LILO\ package.}
  \item[\tt Kernel {\it name} is too big]~\\
    The kernel image (without the setup
    code) is bigger than 512 kbytes. \LILO\ would overwrite itself when trying
    to load such a kernel. Try removing some unused drivers and compiling
    the kernel again.
  \item[\tt Partition entry not found]~\\
    The partition from which an other
    operating system should be booted isn't listed in the specified
    partition table. This either means that an incorrect partition
    table has been specified or that you're trying to boot from a
    logical partition. The latter usually doesn't work. You can bypass
    this check by omitting the partition table specification (e.g.
    omitting the variable \verb"table").
  \item[\tt Sorry, don't know how to handle device \it number]~\\
    \LILO\ uses files that are located on a device for which
    there is no easy way to determine the disk geometry. Such devices have
    to be described in the file {\tt /etc/lilo/disktab}.
\end{description}


\subsection{\LILO\ start message}

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.

\begin{description}
  \item[\rm ({\it 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.
  \item[\tt L\it error$\ldots$] 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. (See also section
    \ref{bioserr}.) This condition usually indicates a media failure or a
    geometry mismatch (e.g. bad parameters in {\tt /etc/lilo/disktab}).
  \item[\tt LI] The first stage boot loader was able to load the second
    stage boot loader, but has failed to execute it. This can either be
    caused by a geometry mismatch or by moving {\tt /etc/lilo/boot.b} without
    running the map installer.
  \item[\tt 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 by a geometry mismatch.
  \item[\tt 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 {\tt /etc/lilo/boot.b} without running the map
    installer.
  \item[\tt LIL-] The descriptor table is corrupt. This can either be caused
    by a geometry mismatch or by moving {\tt /etc/lilo/map} without running
    the map installer.
  \item[\tt LILO] All parts of \LILO\ have been successfully loaded.
\end{description}


\subsection{Disk error codes}
\label{bioserr}

If the BIOS signals an error when \LILO\ is trying to load a boot
image, the respective error code is displayed. The following BIOS
error codes are known:

\begin{description}
  \item[\tt 0x00] {\it 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 re-building the map file.
  \item[\tt 0x01] {\it Illegal command}. This shouldn't happen.
  \item[\tt 0x02] {\it Address mark not found}. This usually indicates
    a media problem. Try again several times.
  \item[\tt 0x03] {\it Write-protected disk}. This shouldn't happen.
  \item[\tt 0x04] {\it 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 {\tt /etc/lilo/disktab} file corresponds
    to the real disk geometry. (See section \ref{disktab}.) Removing
    {\tt compact} may help too.
  \item[\tt 0x06] {\it Change line active}. This should be a transient
    error. Try booting a second time.
  \item[\tt 0x08] {\it DMA overrun}. This shouldn't happen. Try booting
    again.
  \item[\tt 0x09] {\it DMA attempt across 64k boundary}. This shouldn't
    happen. Try omitting the {\tt -c} option and report this problem to
    the author.
  \item[\tt 0x0C] {\it Invalid media}. This shouldn't happen and might
    be caused by a media error. Try booting again.
  \item[\tt 0x10] {\it 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.   
  \item[\tt 0x20] {\it Controller error}. This shouldn't happen.
  \item[\tt 0x40] {\it Seek failure}. This might be a media problem. Try
    booting again.
  \item[\tt 0x80] {\it 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.
\end{description}


\subsection{Other problems}

This section contains a collection of less common problems that have been
observed.

\begin{itemize}
 \item For yet unknown reasons, \LILO\ may fail on some systems with
   AMI BIOS if the ``Hard Disk Type 47 RAM area'' is set to ``0:300''
   instead of ``DOS 1K''.
\end{itemize}

\end{document}
