comp.org.uk

Networking | Programming | Security | Linux | Computer Science | About

How the Linux Boot Process Works

Let’s face it: As enjoyable as the experience of staring at a dormant computer is, the real fun starts when you turn the computer on. As with any electronic device, opening the electron floodgate is the first step to fun. A computer, however, has much more stuff to do than your toaster oven, for example. Rather than act as a simple heating element, your computer has to check all those gizmos that you (or the manufacturer) plugged into your computer’s motherboard. After the initial power-up, the computer performs some simple hardware tests to determine whether those various components are working properly.

Checking all your hardware is just the beginning. Between the time you turn the computer on and the moment the glowing phosphor on your monitor prompts you for a login name, the computer is building itself an empire. If you listen and watch carefully, your computer and monitor show signs of the boot process through bleeps, buzzes, whirring motors, clicks, messages on the monitor, and blinking lights. In this section, I help you identify each stage in the boot process.

Although you have heard the cliché “Rome wasn’t built in a day,” the boot process goes fairly quickly. This is pretty amazing, considering that the architecture of an operating system makes Rome’s look like a stack of cardboard boxes and that each time you power up your computer, it must build its whole operating system in memory. (Remember that an operating system is software that resides between your programs and the computer hardware.) Electrons move at the speed of light, of course, which gives the computer an advantage over the Romans — but that’s enough jibber-jabber.

Making certain that this operating-system software is installed and running correctly is the purpose of the boot process. This process can be broken into four main steps, which I discuss in the following sections.

Step 1: Power-On Self-Test (POST)

The POST process really has nothing to do with the operating system. Your computer performs this step whether you’re running Linux or another operating system. Inside your computer is a chip containing a program that carries out the POST process. The program:

  1. Checks your computer to ensure that fundamental components are functioning properly.
  2. Counts and tests memory. 3. Verifies that no resource conflicts exist for the current adapters and settings, kind of like a traffic cop.
  3. Performs certain basic tests to verify whether each system component is working properly. (The set of rules that determine how these components communicate is called the BIOS, or Basic Input-Output System.)

Some symptoms of a failed POST include:

If you encounter any of these problems, you have hardware problems that need to be resolved before you can proceed. Chances are, if your computer was running properly before you began your Linux installation, your computer should be getting through the POST just fine. If not, it’s time to question your nephew Mortimer, who was last seen lurking around your computer with a screwdriver. Step

2: The BIOS passes the baton to the boot loader

After the BIOS gives the okey-dokey with a successful POST, the BIOS locates the first hard drive in your system and reads the first sector of that disk. On that first chunk of disk is a small program called a boot loader. The boot loader doesn’t know much about anything, except how to load your operating system.

Two boot loader programs understand how to load a Linux operating system: LILO (LInux LOader) and GRUB (GRand Unified Boot loader). LILO has been a tried-and-true boot loader for as long as Linux has been a gleam in a geek’s eyeball. GRUB is a newer and much more sophisticated boot loader program than LILO. The current version of Fedora Core allows you to choose your boot loader, but uses GRUB by default.

I recommend that you stick with whatever your chosen distribution uses by default. This boot loader has the best support with the distribution’s built-in software.

One common symptom of a missing or corrupt boot loader is a message saying that the operating system could not be found. To get the boot loader working again, reinstall the boot loader to the master boot record of your first drive. I explain later in this chapter how to reload and install the boot loader. You may also see this message if the disk geometry has changed in the BIOS from the time you installed the operating system. If, for some reason, you change the heads, tracks, and sectors setting, the BIOS may not be able to find the first sector on the first drive.

Step 3: The boot loader (GRUB or LILO) loads the system kernel into memory

A boot loader is a program that understands how to load a system kernel into memory. A kernel is the software at the heart of any operating system and communicates directly with the hardware. For example, when you choose to save a file in your word processor application, your word processor is making a request to the kernel to perform the saving of the file to disk. The loaded kernel acts as the maestro, orchestrating all the components of your computer and delegating resources in a logical and cooperative manner. The boot loader is the red carpet on which the maestro enters.

This list shows some symptoms of a missing, incorrect, or corrupt system kernel:

You know when the kernel is loading because several screens full of kernel messages scroll up your monitor. Note that a kernel error results in a wide variety of symptoms because the loading of the kernel is the first introduction of Linux to your hardware. With a seemingly infinite combination of computer components, making certain that they’re compatible can be a challenge — especially with really old or really new hardware. Kernel support for this type of hardware may be minimal or nonexistent.

The remedy for an apparent missing kernel is to correctly tell the boot loader where to find the kernel. Although this task can be relatively easy to do with GRUB, it requires a crowbar and a rescue disk with LILO.

One key step in installing Linux on your computer is the configuration of a boot loader. If your installation is successful, you never need to give another thought to this component. It just runs silently each time you turn on your machine. However, some situations require that you interact with the boot loader program. You may want to start Linux in a mode other than the default, for example, or perhaps you need to pass special information regarding a new adapter you just installed.

The way you invoke the boot loader depends on your Linux distribution. The text displayed on your monitor following the power-on typically provides you with instructions. If you loaded the GRUB boot loader, you can get to an interactive prompt by pressing A.

The GRUB manual is available online at www.gnu.org/manual/grub-0.92/grub.html

Step 4: Control is handed over to init

Up to this point in the boot process, only the components that run behind the scenes have been loaded. A program named init is the common ancestor to all other programs that run while the system is operating. The init program is responsible for starting all services and programs. You can see these processes starting as they scroll up the screen with [OK] or [FAILED] on the right side of the monitor. If you see these lines, you know that your kernel has loaded.

The only problems you may encounter with init are services that fail to load, as is indicated by the [FAILED] status. Many of these services don’t keep you from logging in and using your system. Services usually fail because of misconfigurations or unsupported hardware drivers.


Published on Fri 02 March 2001 by Lai Yahui in Linux with tag(s): boot lilo grub