Chapter 5
LILO: From "power on" to "Loading linux..."
|
|
|
|
|
 |
In this chapter: |
|
|
|
  |
General overview of the booting process
|
  |
Exploring the Linux Loader LILO and its configuration
|
  |
SuSE's default LILO settings
|
  |
Customizing the LILO setup
|
|
|
|
 |
|
|
5.1 | The Four Steps of the Booting Process |
|
In this section, we discuss nearly everything that goes on from the
moment you push the "power on" button until the login: prompt
appears. This sequence of events can be roughly divided into four
steps: hardware initialization, bootloader/system selection, kernel
initialization, and invocation of init.
|
5.1.1 | Hardware initialization |
|
Hardware initialization is a PC's normal power-up routine. It usually
checks its memory, initializes devices, and powers up its own BIOS and
the BIOSes of intelligent adapters, such as SCSI and so on. It then
searches for bootable devices, which in most BIOSes can be selected in
the BIOS setup. These are usually the floppy disk, hard disks, and, in
newer BIOS versions, the CD-ROM.
|
5.1.2 | Bootloader/System selection |
|
After this first step, the BIOS loads the boot sector of the first
valid boot device and runs this code. The boot sector is the very
first sector of this device. It has to contain a loader routine, which
either starts up the operating system or presents the user with a
selection, such as which OS to start.
The most commonly used boot loader on Linux systems is LILO (LInux
LOader). Because this is also the one that is shipped with SuSE
Linux, we concentrate on this one. LILO allows you to boot only
Linux, or it can present a boot menu, which makes choosing among
several installed operating systems at boot time possible.
|
5.1.3 | Kernel initialization |
|
We assume here that you selected Linux as the OS to boot. This means
that LILO loads the kernel image into RAM and executes it. Now the
Linux kernel takes over the control of the system. It initializes
itself, eventually autoprobes devices, initializes detected devices,
and, if all this is done, it starts init, the process that parents
all other user-level processes of the system.
|
5.1.4 | Invocation of init |
|
Now you are at the point where you can choose where to go. The init
process reads its configuration file (/etc/inittab) and
processes scripts or commands instructed in this file.
|
 |
You can see in Chapter 6
how this works and how you
can modify the behavior of init or add your own
extensions to it.
|
|
During the first step, hardware initialization, you won't find many
customizable options. You'll find instructions on how to modify BIOS
settings in your main board manual. If you have adapters that have
their own BIOS, check these manuals in case you must or can change
something. We silently ignore this part of bootup in the following
sections.
The first interesting event is when LILO is invoked, which is where we
start now.
|
5.2 | Introducing LILO |
|
LILO is the Linux Loader, a tool that is used to load the Linux
operating system. More specifically, LILO is a collection of several
programs and other files that we examine in the following sections.
|
5.2.1 | The map installer |
|
The map installer is the program you run underneath Linux to place all
files that belong to LILO in the appropriate places and to record
information about the location of any data needed at boot time. This
program resides in /sbin/lilo. Whenever any part of the
system changes, such as by the installation of a new kernel, this
program has to be run again to refresh the information it holds.
|
5.2.2 | Data files |
|
A collection of various files that contain data LILO needs at boot
time. These files reside in /boot. The most important
files are the boot loader (see the following section) and the map file
(/boot/map), which is where the map installer records the
location of the kernel. Another important file is the configuration
file, which is /etc/lilo.conf.
|
5.2.3 | The boot loader |
|
This is the part of LILO that is loaded by the BIOS and that loads the
kernel or the boot sector of other operating systems. It also
provides a simple command-line interface to interactively select
the item you wish to boot and allows you to add boot options.
|
 |
Much of this information is taken from Werner Almesberger's excellent
LILO documentation. If you run into trouble with LILO and find that
this book doesn't have an answer for you, refer to his LILO docs.
You find them in /usr/doc/packages/lilo. The
README is very extensive and provides almost everything
you never knew you wanted to know about LILO. It also has an
excellent trouble shooting section. This section contains nothing that
you can't find in Werner's LILO user's guide.
|
|
On SuSE systems, YaST (Yet Another Setup Tool) makes the LILO
configuration fairly easy. Simply fill out the form "LILO
INSTALLATION" and YaST will do the rest. If this works for you, and
you don't want to change anything, just skip this chapter and continue
in Chapter 6
. But if you are interested in using LILO for passing
parameters or booting into different configurations, you'll want to
read on in this chapter.
|
5.3 | Installing LILO |
|
If you can think of LILO as the god Janus, it will help you remember
that it has two distinct "faces." One "face" is visible when you boot
your system, the other when you install it on your system. Before we
talk about the actual boot loader (see next section) we provide a
closer look at installing LILO.
The map installer /sbin/lilo reads its configuration file
/etc/lilo.conf and modifies either the master boot record or the
boot record of the root partition, depending on the settings recorded
in the configuration file. YaST generates a decent configuration
file that works for most systems. It has one global section and at
least one image section.
If you have more than one image section, you can decide at boot time
which one to use. Image sections can point to different kernels,
provide different parameters for the boot up, or describe different
operation systems. By default, the first image listed will be booted
if you do not specify otherwise at boot time. The global section
sets parameters that are valid for all image sections.
|
5.3.1 | YaST configures LILO |
|
Because most SuSE users use YaST to set up LILO (which is a good way
to do it), we take a closer look at what YaST does with LILO before we
discuss possible ways to optimize it. YaST puts the following entries
in the global section of /etc/lilo.conf.
|
| boot=boot-device |
|
Sets the name of the device (for example, a hard disk partition) that
contains the boot sector. If boot is omitted, the boot sector is
read from (and possibly written to) the device that is currently
mounted as root.
You'll find a file such as /dev/sda (the device for the first hard
disk) here, if you have selected "Master boot record," or /dev/sda2
(the device for a single partition) if you selected "Boot record of
the root partition" in YaST.
|
| compact |
|
This is commented out by default. It tries to merge read requests for
adjacent sectors into a single read request. This drastically reduces
load time and keeps the map smaller. It may conflict with
linear and doesn't work on all systems. It is worth
trying, but have a boot floppy ready in case your system doesn't
come up.
|
| timeout=value |
|
Sets a timeout (in tenths of a second) for keyboard input. If no key
is pressed during 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. YaST allows you to set the
timeout in seconds, so expect to see values ten times larger than
specified in YaST in this line.
|
| read-only |
|
Specifies that the root file system should be mounted read-only. Don't
change this setting! The SuSE boot scripts check the root file system
and remount it as read-write. It's mandatory that LILO instructs the
kernel to mount the read file system first in read-only mode.
|
| vga=normal |
|
Specifies the VGA text mode that should be selected when booting. The
following values are recognized:
|
|
  |
normal: Select normal 80x25 text mode.
|
  |
extended: Select 80x50 text mode.
|
  |
ask: Stop and ask for user input (at boot time).
|
  |
number: Use the corresponding text mode. A list of available modes can be obtained by
booting with vga=ask and pressing Enter.
|
|
|
|
| linear |
|
Generates linear sector addresses instead of 3D (sector/head/cylinder)
addresses. Linear addresses are translated at run time and do not
depend on disk geometry. Note that boot disks may not be portable if
linear is used, because the BIOS service to determine the disk
geometry does not work reliably for floppy disks. When you're using
linear with large disks, /sbin/lilo may generate
references to inaccessible disk areas, because 3D sector addresses are
not known before boot time. The linear switch may conflict with
compact and is known to be problematic on many
systems. In YaST, you can switch this flag on or off.
Like compact, it may be worth trying, because it may also speed up the
boot process. Again, be prepared to boot from a floppy disk. On the
other hand, it's also required by some older BIOS versions. So if
your system doesn't boot without the linear option, try to set it.
|
| append=string |
|
Appends the options specified in 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. You can specify the
append string in YaST. This option has lost some importance with the
introduction of the modular kernel. It is very useful to pass IRQs
or addresses of i/o ports to specific drivers, but because most
drivers are loaded as modules now, you may choose to enter those
parameters in /etc/conf.modules.
The per image section generated by YaST is rather simple. YaST allows
you to select among three different image types: Linux, DOS,
and OS/2. To boot Linux, it generates an entry like this:
|
|
# Linux bootable partition config begins
image = /boot/vmlinuz
root = /dev/hda2
label = Linux
# Linux bootable partition config ends
|
|
|
| image=/boot/vmlinuz |
|
This entry points to the kernel image to boot. Please note that due to
limitations of PC BIOSes, the kernel has to be on the first or second
hard drive and has to be located below the 1024 cylinders margin. The
reason for this is that the boot loader loads the kernel image into
RAM using BIOS calls. The BIOS can usually access only the first two
hard drives (most SCSI adapters have their own BIOS and this
restriction may not apply to them) and it can address only 1024
cylinders. This is why SuSE creates a partition /boot
where the kernel and the LILO data files are placed. This partition
must be located below 1024 cylinders.
|
| root=/dev/hda2 |
|
Specifies the device that should be mounted as root. If the unique
name current is used, the root device is set to the device on which
the root file system is currently mounted. If the variable
root is omitted, the root device setting contained in the
kernel image is used. It can be changed with the rdev program.
Again, YaST uses your selection for this directive.
|
| label=Linux |
|
By default, LILO uses the main filename (without its path) of each
image specification to identify that image. YaST prompts for a name
and uses your entry as a label.
The image sections for DOS and OS/2 look like this:
|
|
# DOS bootable partition config begins
other = /dev/hda1
label = Win95
table = /dev/hda
# DOS bootable partition config ends
#
# OS/2 bootable partition config begins
other = /dev/hdb1
label = OS2
loader = /boot/os2_d.b
table = /dev/hdb
# OS/2 bootable partition config ends
|
|
Some key words follow.
|
| other=/dev/hda1 |
|
Specifies the image of a foreign OS. Normally, this is the boot
partition of the operating system but can also be a file.
|
| loader=/boot/os2_d.b |
|
Specifies the chain loader that should be used. If it is omitted,
/boot/chain.b is used. YaST makes the entry seen in the
OS/2 section only for OS/2 systems on the second hard drive.
Os2_d.b is a special loader for loading OS/2 from the
second hard drive. The default loader chain.b works fine
for DOS, Windows, NT, and other systems.
|
| table=/dev/hda |
|
Specifies the device that contains the partition table. If this
variable is omitted, LILO does not pass partition information to the
booted operating system. (Some operating systems have other means to
determine which partition they have been booted in; for example,
MS-DOS usually stores the geometry of the boot disk or partition in
its boot sector.) Note that /sbin/lilo must be rerun if a reference
to a partition table mapping with table is modified.
After YaST writes /etc/lilo.conf, it runs
/sbin.lilo and presents the user the output of the map
installer:
|
|
Added linux *
Added Win95
Added OS2
|
|
The asterisk indicates the default image. If the LILO output looks like
this, everything went fine. If there was an error, LILO will tell
you what went wrong. In most cases, everything goes smoothly.
|
 |
If you are unlucky enough to run into problems with LILO, consult
Werner Almesberger's documentation, which is mentioned earlier in this
chapter. Werner has done a great job describing what can happen during
these rare incidences, and offers thorough trouble shooting
techniques. We limit our focus to possible system options rather than
error resolution.
|
|
|
5.3.2 | Going further with additional options |
|
For most people, YaST's default settings are sufficient. It's a handy,
reliable way to boot Linux in other OSes from the hard drive of the
system. For those of you who want additional features, read on.
One convenient feature is the ability to display a message at boot
time. It can be as simple as a greeting, or it can be quite
functional, such as a list of available boot options. To do this,
generate a file containing the message (max size 64K) and add a
pointer to this file in the global section of /etc/lilo.conf:
|
|
message = /boot/my_message
|
|
|
 |
Don't forget to rerun the map installer after you add or change the
message or move the file.
|
|
|
 |
Another useful trick is to move some of the global options into the
image-specific sections. For example, if you want to check out how
certain things work if memory is low, you can add an image section
like this to boot into a system that uses only 12MB of RAM:
|
|
# Low memory Linux
image = /boot/vmlinuz
append = "mem=12M"
root = /dev/hda2
label = LowMem
|
|
|
|
You can have LILO record any options you create or decide not to
use. LILO can be instructed to make them the default settings whenever
you boot your system. Just put the lock parameter in the image
section, and LILO will keep your options until you choose to override
them at the boot prompt, or when you rerun the map installer.
|
| Boot passwords |
|
LILO supports a password request prompt before it boots the
system. This precaution is necessary because many simple schemes
exist that will allow root access to anyone who can boot your
system and knows the LILO prompt.
|
 |
To activate the password request, add the following line either to the
image sections or to the global section. Putting it in the global
section will protect all images, whereas placing it in an image
section protects only that image. This way, you can have different
passwords for different operating systems. Thus, you can allow
everyone to boot into Windows, but require a password for users to
boot into Linux.
|
|
# Password protection for system boot
password=<your-password>
|
|
|
|
To lower the level of protection, you can add the keyword
restricted to your configuration. This means that only a
password is needed when arguments are passed to the kernel. The
restricted keyword works only in conjunction with
password.
Many other options are available for any particular situation you may
find yourself in. Again, refer to Werner Almesberger's documentation
for more on LILO.
|
5.4 | Lilo loads Linux |
|
Now that you have seen the configuration options, you can see LILO in
action. As explained earlier, the boot loader part of LILO allows you
to make certain selections and to pass parameters at boot time. So we
now assume that you have installed LILO on your system and have
rebooted.
After the hardware performs its init, you'll see the LILO prompt and,
if you installed a message file, a greeting like this:
|
|
---------------------------------------------------------------
Please select the OS you want to boot:
Linux -> SuSE Linux 6.0
LowMem -> SuSE Linux 6.0 with only 12MB RAM avail.
Win95 -> MS Windows'95
OS2 -> OS/2
or press [Enter] to boot Linux. If you do nothing, Linux
will boot after a 10 second delay.
---------------------------------------------------------------
boot:
|
|
The system will pause at this point until you select an option, press
Enter, or the timeout period is over. In the two latter cases, the
default image will be loaded without additional parameters.
To select an image other than the default one, type the name of the
image at the prompt and press Enter:
|
|
boot: LowMem
|
|
This will boot the image with the 12MB restriction. You can press the
Tab key to get a list of all possible options.
If you choose to boot a Linux image, you also can pass parameters to
the kernel and to init. That is, if you use a standard setup but
you want to limit the available memory, you can tell the kernel to
use 12MB only at the LILO boot:-prompt:
|
|
boot: Linux mem=12M
|
|
The parameter line is passed to the Linux kernel. The kernel reads all
parameters it understands, removes them from the parameter line, and
passes the remaining entries to init. This allows it to
pass parameters to both the kernel and init on one line. This is the
default option. However (and here is one of the schemes mentioned
earlier), you can also specify the init binary to be started after
the kernel has finished its initialization. The following parameters
on the boot prompt will result in an open root shell right after
the system boots. No password, request, nothing:
|
|
boot: Linux init=/bin/bash rw
|
|
The kernel is told to start /bin/bash rather than init,
and to mount the root partition read-write. It's commonly held that
breaking into a Linux system is simple if you have a boot floppy with
a small rescue system on it. But as you see, it's even easier than
that: no floppy needed, just some parameters at the LILO prompt.
|
 |
Before you try doing this on your system, beware of the fact that it's
easy to create a mountain of problems. There is no file system
check, no controlled unmounting before reboot, and so on. You are
on your own if you start your system this way.
|
|
|
 |
More about security can be found in Chapter 23
.
|
|
In general, passing parameters is a nice feature. You can not only use
it to give information to the kernel, but also, as the kernel passes
parameters on to init, you can boot into certain runlevels right from
the boot prompt. Here's a common problem that will illustrate how you
can use the LILO/init feature. Say that you selected a
graphical login, but for some reason, the X server configuration is
corrupted.
When you select the graphical login screen in YaST, the system boots
into runlevel three, which is the default. If your X server starts up
okay, great. If not, things can get messy. X will simply start and
die, start and die, and start and die repeatedly, offering you no way
to login and fix the problem or even allowing you to switch to
runlevel two, where X will not be started by default.
|
 |
What to do? You can press Ctrl+Alt+Del to reboot the system, which is
almost all you can do in this situation, but as you'll see, it's often
enough to fix the problem. Press Ctrl+Alt+Del and you'll return to the
LILO prompt. Now, rather than simply boot the system, you should
specify the runlevel you want to boot into on the command line:
|
|
boot: Linux 2
|
|
Because the kernel is unaware of the parameter 2, it passes it on to
init, and init reacts by not going to the
default runlevel (three in this case), but by booting into runlevel
two. Now you get your console login and can begin to work on the
problem with the X server.
|
|
This should be sufficient information about LILO and this stage of the
boot process. The boot loader loads the kernel image into RAM and
starts it. At this point (drum roll, please) Linux is now in charge
of your system!
|
5.5 | Linux: The kernel takes the stage |
|
After the boot loader starts the kernel, it powers itself up, analyzes
the hardware, and initializes drivers and internal data
structures. The kernel prints lots of messages on the screen while
starting up. You may want to examine these closely, in case you have
some hardware that isn't functioning properly.
|
 |
Because the messages scroll quickly up the screen, it's good to know
that you can halt the output by pressing Ctrl+S. Ctrl+Q switches
back to normal mode.
You can page back and forth with the key combinations Shift+PageUp
and Shift+PageDown.
|
|
Most of the boot messages are always held (well, until the system gets
booted again) in the file /var/log/boot.msg.
That's it -- there's not very much to say about the kernel start up,
but the really interesting part is coming, which is when the kernel
starts init. Before init gets started, the root file
system is mounted in read-only mode. These are the last two steps the
kernel performs before switching into user mode and letting init take
control. Read on in Chapter 6
.
|
 |
Summary: |
|
The Linux loader LILO presents a prompt at boot time that allows you
to select which image you prefer to boot. With Linux, it loads the
kernel and executes it. SuSE automatically configures LILO in a way
that works on most systems. However, LILO has many more options than
the few that are used by SuSE. LILO also offers the option to pass
parameters to the kernel and the init process, which can be used to
work around temporary problems, or to temporarily build special
environments.
|
 |