2.5. LILO and GRUB

During boot-up, boot loaders need to know where the kernel is (usually in /boot) and which device is the root-device.

BOOTLOADER → KERNEL → / → /sbin/init

Alternatively, a boot loader can load a RAM disk into memory containing scripts and kernel modules needed to access the root device. This will be the case when the root-device is handled by non-resident (also called dynamic) modules.

BOOTLOADER → INITRD → KERNEL → / → /sbin/init

Table 2.3. Common dynamic modules

ext3Third extended filesystem type
lvmLogical volume support
raidxsoftware raid level x support
scsiSCSI support

2.5.1. Installing LILO

The bootloader LILO is installed by /sbin/lilo (the bootloader mapper or installer) which in turn reads configuration options from the file /etc/lilo.conf.

LILO cannot read filesystems, only offsets on the physical disks. Therefore the mapper will read information from the /etc/lilo.conf file (e.g which second stage bootloader to use, which kernel or which initial ram disk) and will translate this information using a system of maps for LILO to read at boot time.

The main options in /etc/lilo.conf are specified here

boot*where LILO should be installed (/dev/hda is the MBR)
installwhich second stage to install (boot.b is the default)
promptgive the user a chance to choose an OS to boot
defaultname of the image that will be booted by default
timeoutused with prompt, causes LILO to pause (units are 1/10 of a sec)
image*path to the kernel to boot (one can use other to chain load)
label*name of the image. This is the name a user can type at the boot prompt
root*the name of the disk device which contains the root filesystem /
read-only*mount the root filesystem read-only for fsck to work properly
appendgive kernel parameters for modules that are statically compiled.
linear/lba3these options are mutually exclusive. Both ask LILO to read the disk using Linear Block Addressing. linear is typically used for very large disks. lba32 is used to allow boot time access to data beyond the first 1024 cylinders

2.5.2. Installing GRUB

The GRUB boot loader is installed with the command grub-install. Configuration options are stored in the file /boot/grub/menu.lst or /boot/grub/grub.conf. Unlike LILO, GRUB is a small shell that can read certain filesystem. This allows GRUB to read information in the grub.conf or menu.lst files.

Main sections in /boot/grub/grub.conf:or menu.lst

  1. General/Global

    defaultimage that will boot by default (the first entry is 0)
    timeoutprompt timeout in seconds
  2. Image

    titlename of the image
    rootwhere the 2nd stage bootloader and kernel are e.g (hd0,0) is /dev/hda
    kernelpath for the kernel starting from the previous root e.g /vmlinuz
    roread-only
    rootthe filesystem root
    initrdpath to the initial root disk

2.5.3. Bootloader Options

It is possible to give parameters at boot time to both LILO and GRUB. Both loaders have a limited interface which can read user input.

Example 2.1. Passing parameters at the LILO prompt

boot: linux s

Example 2.2. Passing parameters at the GRUB prompt

Once the GRUB boot loader has successfully started you will see the main menu screen with a list of menu titles.

Do the following:

  1. press 'e' to edit a given menu title

  2. scroll down to the line containing 'kernel' and press 'e' again

  3. you can add any options here

  4. to boot with the current options type 'b'. Otherwise just press return to get the unaltered line back

Notice that pressing the ESC key will bring you back to a previous stage. You can navigate back to the main menu this way.

Alternatively the boot loader configuration files (lilo.conf or grub.conf) can be used to save these option

2.5.4. Passing init parameters

Boot loaders can passe the runlevel parameter to init. Once the kernel is loaded, it will start /sbin/init by default which then takes over the booting process.

Common runlevels are s, single, S, 1, 2, 3, 4, 5

If no parameters are given, init will launch the default runlevel specified in /etc/inittab.

2.5.5. Parsing Kernel Parameters

Kernel options are of the form item=value.

Table 2.4. Common kernel parameters

acpi=enable/disable ACPI
init=tell the kernel which program to start from the root device
mem=specify amount of RAM to use
root=specify the root device
[Warning]Warning

The boot loader kernel parameters are passed to the resident kernel modules only. To pass parameters to non resident modules one can do this using /etc/modules.conf see Section 1.2, “The Modular Kernel”

In /etc/lilo.conf kernel parameters are declared with the append option.

Examples

append="pci=bisoirq"
append="ram=16M"
append="/dev/hdc=ide-scsi"   (for CD writers)

During bootup all kernel messages are buffered and dumped to /var/log/dmesg as soon as filesystems are loaded. This file can then be read after the system has boot and will contain only information about the booting kernel. Subsequent kernel events are continously looged and can be displayed using the /bin/dmesg utility.