Book: LPI Linux Certification in a Nutshell Section: Chapter 14. Linux Installation and Package Management (Topic 2.2)
### 14.2 Objective 2: Install a Boot Manager While it is possible to boot Linux from a floppy disk, most Linux installations boot from the computer's hard disk.[2] 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: [2] This isn't to say that you can't boot from other media such as floppies -- many people do. Run lilo from the boot disk It is Linux loader's (LILO'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 LILO starts the loaded kernel. LILO'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. #### 14.2.1 LILO The Linux Loader (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. While other boot loaders exist, LILO is the most popular and is installed as the default boot loader on most Linux distributions. LILO consists of two parts: The boot loader This part of LILO is a two-stage program intended to find and load a kernel.[3] The first stage of LILO usually resides in the Master Boot Record (MBR) 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. [3] 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 lilo command Also called the map installer, lilo is used to install and configure the LILO boot loader. The lilo command reads a configuration file, which 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. ##### 14.2.1.1 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: <TAB>
    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. ##### 14.2.1.2 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 in the MBR, customized for your particular system. Your installation program will do it, then you'll repeat it manually if you build a new kernel yourself.
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, while others are specific to a particular listed kernel image. Most basic Linux installations use only a few of the configuration options. Example 14-1 shows a simple LILO configuration file. ##### Example 14-1. Sample /etc/lilo.conf File
    boot = /dev/hda
    timeout = 50
    prompt
    read-only
    map=/boot/map
    install=/boot/boot.b
    image = /boot/vmlinuz-2.2.5-15
      label = linux
      root = /dev/hda1
Each of these lines is described in the following list: boot The boot directive tells lilo 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 The timeout directive 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 This directive instructs 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 This directive specifies that the root filesystem should initially be mounted read-only. Typically, the system startup procedure will remount it later as read/write. map The map directive specifies the location of the map file, which defaults to /boot/map. install The install directive specifies the file to install as the new boot sector, which defaults to /boot/boot.b. image An image line specifies a 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 The optional label parameter is used after an image line and offers a label for that image. This label can be anything and generally describes the kernel image. Examples include `linux`, or perhaps `smp` for a multiprocessing kernel. root This parameter is used after each image line and specifies the device to be mounted as root for that image. 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. A discussion on using LILO to boot multiple kernels is presented in Chapter 15. ##### 14.2.1.3 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 such as Windows, you should place its boot loader in the boot sector.[4] [4] 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.