Read LPI Linux Certification in a Nutshell Online

Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger

Tags: #Reference:Computers

LPI Linux Certification in a Nutshell (8 page)

BOOK: LPI Linux Certification in a Nutshell
12.68Mb size Format: txt, pdf, ePub
ads
Objective 2: Install a Boot Manager

Although it is possible to boot Linux from a floppy disk,
most Linux installations boot from the computer’s hard disk. This is a
two-step process that begins after the system BIOS is
initialized and ready to run an operating system. Starting Linux consists
of the following two basic phases:

Run the boot loader from the boot
device

It is the boot manager’s job to find the selected kernel and
get it loaded into memory, including any user-supplied
options.

Launch the Linux kernel and start
processes

Your boot loader starts the specified kernel. The boot
loader’s job at this point is complete and the hardware is placed
under the control of the running kernel, which sets up shop and
begins running processes.

All Linux systems require some sort of boot loader, whether it’s
simply bootstrap code on a floppy disk or an application such as LILO or
GRUB. Because the popularity of GRUB has grown, LPI has added it to the
second release of the 101 exams.

LILO

The LILO is a small utility designed to load the Linux
kernel (or the boot sector of another operating system) into memory and
start it. A program that performs this function is commonly called a
boot loader. LILO consists of two parts:

The boot loader

This is a two-stage program intended to find and
load a kernel. It’s a two-stage operation because the boot sector
of the disk is too small to hold the entire boot loader program.
The code located in the boot sector is compact because its only
function is to launch the second stage, which is the interactive
portion. The first stage resides in the MBR or first boot
partition of the hard disk. This is the code that is started at
boot time by the system BIOS. It locates and launches a second,
larger stage of the boot loader that resides elsewhere on disk.
The second stage offers a user prompt to allow boot-time and
kernel image selection options, finds the kernel, loads it into
memory, and launches it.

The lilo command

Also called the
map installer
, the
lilo
command is used to install and configure
the LILO boot loader. The command reads a
configuration file that describes where to find
kernel images, video information, the default boot disk, and so
on. It encodes this information along with physical disk
information and writes it in files for use by the boot
loader.

The boot loader

When the system BIOS launches, LILO presents you with the
following prompt:

LILO:

The
LILO
prompt is designed
to allow you to select from multiple kernels or operating systems
installed on the computer and to pass parameters to the kernel when it
is loaded. Pressing the Tab key at the LILO prompt yields a list of
available kernel images. One of the listed images will be the default
as designated by an asterisk next to the name:

LILO:

linux* linux_586_smp experimental

Under many circumstances, you won’t need to select a kernel at
boot time because LILO will boot the kernel configured as the default
during the install process. However, if you later create a new kernel,
have special hardware issues, or are operating your system in a
dual-boot configuration, you may need to use some of LILO’s options to
load the kernel or operating system you desire.

The LILO map installer and its configuration file

Before any boot sequence can complete from your hard disk, the
boot loader and associated information must be installed by the LILO
map installer utility. The
lilo
command writes
the portion of LILO that resides to the MBR, customized for your
particular system. Your installation program creates a correct MBR,
but you’ll have to repeat the command manually if you build a new
kernel yourself.

LILO locations

During installation, LILO can be placed either in the
boot sector of the disk or in your root partition. If the system is
intended as a Linux-only system, you won’t need to worry about other
boot loaders, and LILO can safely be placed into the boot sector.
However, if you’re running another operating system you should place
its boot loader in the boot sector. Multiple-boot and multiple-OS
configurations are beyond the scope of the LPIC Level 1 exams.

On the Exam

It is important to understand the distinction between
lilo
, the map installer utility run
interactively by the system administrator, and the boot loader,
which is launched by the system BIOS at boot time. Both are parts of
the LILO package.

GRUB

GRUB is a multistage boot loader, much like LILO. It is
much more flexible than LILO, as it includes support for booting
arbitrary kernels on various filesystem types and for booting several
different operating systems. Changes take effect at once, without the
need for a command execution.

GRUB device naming

GRUB refers to disk devices as follows:

(
x
d
n
[,
m
])

The
x
d
in this example will be either
fd
or
hd

floppy disk
or
hard
disk
, respectively. The
n
refers
to the number of the disk as seen by the BIOS, starting at
0
. The optional
,
m
denotes the
partition number, also starting at
0
.

The following are examples of valid GRUB device names:

(fd0)

The first floppy disk

(hd0)

The first hard disk

(hd0,1)

The second partition on the first hard disk

Note that GRUB does not distinguish between IDE and SCSI/SATA
disks. It refers only to the order of the disks as seen by the BIOS,
which means that the device number that GRUB uses for a given disk
will change on a system with both IDE and SCSI/SATA if the boot order
is changed in the BIOS.

Installing GRUB

The simplest way to install GRUB is to use the
grub-install
script.

For example, to install GRUB on the master boot record of the
first hard drive in a system, invoke
grub-install
as follows:

#
grub-install '(hd0)'

grub-install
looks for a device map file
(
/boot/grub/device.map
by default) to determine
the mapping from BIOS drives to Linux devices. If this file does not
exist, it will attempt to guess what devices exist on the system and
how they should be mapped to BIOS drives. If
grub-install
guesses incorrectly, just edit
/boot/grub/device.map
and rerun
grub-install
.

The device map file contains any number of lines in this
format:

(
disk
) /dev/
device

So, for example, on a system with a floppy and a single SCSI
disk, the file would look like this:

(fd0)   /dev/fd0
(hd0) /dev/sda

GRUB can also be installed using the
grub
command. The
grub-install
example shown earlier
could also have been done as follows, assuming
/boot
is on the first partition of the first hard
disk:

#
grub
grub>
root (hd0,0)
grub>
setup (hd0)
Booting GRUB

If there is no configuration file (or the configuration file
does not specify a kernel to load), when GRUB loads it will display a
prompt that looks like this:

grub>

GRUB expects a certain sequence of commands to boot a Linux
kernel. They are as follows:

  1. root
    device

  2. kernel
    filename
    [
    options
    ]

  3. initrd
    filename
    – optional, only present if an
    initial ramdisk is required

  4. boot

For example, the following sequence would boot a stock Red Hat
8.0 system with
/boot
on
/dev/hda1
and
/
on
/dev/hda2
:

grub>
root (hd0,0)
grub>
kernel /vmlinuz-2.4.18-14 ro root=/dev/hda2
grub>
initrd /initrd-2.4.18-14.img
grub>
boot
The GRUB configuration file

GRUB can be configured to boot into a graphical menu, allowing
the user to bypass the GRUB shell entirely. To display this menu, GRUB
needs a specific configuration file,
/boot/grub/menu.lst
.

Note

The location of this file may be different on your system. For
example, on Red Hat systems the default configuration file is
/boot/grub/grub.conf
.

The configuration file defines various menu options along with
the commands required to boot each option. The earlier example of
booting a stock Red Hat Fedora 8.0 system could have been accomplished
with the following configuration file:

default=0
timeout=3
title Red Hat Linux (2.4.18-14)
root (hd0,0)
kernel /vmlinuz-2.4.18-14 ro root=/dev/hda2
initrd /initrd-2.4.18-14.img
Note

GRUB has many more features, including serial console support,
support for booting other operating systems, and so on. For more
information about GRUB, see the info documentation (
info
grub
or
pinfo grub
) or the
online
documentation
.

Name

lilo

Syntax
lilo [
options
]

The
lilo
map installer reads a
configuration file and writes a map file, which contains
information needed by the boot loader to locate and launch Linux
kernels or other operating systems.

Frequently used options
-C config _ file

Read the
config _ file
file
instead of the default
/etc/lilo.conf
.

-m map _ file

Write
map _ file
in place of the
default as specified in the configuration file.

-q

Query the current configuration.

-v

Increase verbosity.

LILO’s configuration file contains options and kernel image
information. An array of options is available. Some are global,
affecting LILO overall, whereas others are specific to a
particular listed kernel image. Most basic Linux installations use
only a few of the configuration options.
Example 5-1
shows a
simple LILO configuration file.

Example 5-1. Sample /etc/lilo.conf file

boot = /dev/hda
timeout = 50
prompt
read-only
map = /boot/map
install = /boot/boot.b
image=/boot/bzImage-2.6.0
label=test-2.6.0
root=/dev/hda1

Each line in the example is described in the following
list:

boot

Sets the name of the hard disk partition device that
contains the boot sector. For PCs with IDE disk drives, the
devices will be
/dev/hda
,
/dev/hdb
, and so on.

timeout

Sets the timeout in tenths of a second (deciseconds)
for any user input from the keyboard. To enable an
unattended reboot, this parameter is required if the
prompt
directive is
used.

prompt

Sets the boot loader to prompt the user. This behavior
can be stimulated without the prompt directive if the user
holds down the Shift, Ctrl, or Alt key when LILO
starts.

read-only

Sets the root filesystem to initially be mounted
read-only. Typically, the system startup procedure will
remount it later as read/write.

map

Sets the location of the map file, which defaults to
/boot/map
.

install

Sets the file to install as the new boot sector, which
defaults to
/boot/boot.b
.

image

Sets the kernel image to offer for boot. It points to
a specific kernel file. Multiple image lines may be used to
configure LILO to boot multiple kernels and operating
systems.

label

Sets the optional label parameter to be used after an
image line and offers a label for that image. This label can
be anything you choose and generally describes the kernel
image. Examples include
linux
and
smp
for a multiprocessing
kernel.

root

Sets the devices to be mounted as root for the
specified image (used after each image line).

There is more to configuring and setting up LILO, but a
detailed knowledge of LILO is not required for this LPI Objective.
It is important to review one or two sample LILO configurations to
make sense of the boot process.

BOOK: LPI Linux Certification in a Nutshell
12.68Mb size Format: txt, pdf, ePub
ads

Other books

Becoming the Alpha by Ivy Sinclair
Spirit's Chosen by Esther Friesner
Lisdalia by Brian Caswell
Carolina Heart by Virginia Kantra
Bitter Eden: A Novel by Tatamkhulu Afrika
Ruffskin by Megan Derr
How a Star Falls by Amber Stokes
Cold Snap by Allison Brennan
The Trap by Kimberley Chambers
Bellissima by Anya Richards