Booting

Scope of this page:

  • give a general overview over the booting process (from BIOS to kernel booted and root mounted)
  • demystify some of the black magic in the dozens of installation howtos
  • give clues for some advanced booting schemes
  • link to more specific instructions and howtos

Boot up phases

There are 4 phases to starting up the system:

  1. BIOS
  2. Boot loader
  3. Kernel
  4. Upstart (which manages system tasks and services )

Some core boot tasks started by upstart are

  1. Plymouth - The graphical boot animation and logger
  2. mountall - Mounts all filesystems defined on /etc/fstab
  3. network* - Network related services
  4. Display Manager (GDM,KDM,XDM,...)

(upstar tasks/services are configured at /etc/init)

BIOS Phase

When the computer begins execution, it starts by executing this code, which is also called the firmware, as it is normally stored in a permanent form of memory, such as ROM, on the computer's motherboard. On a Macintosh computer this is the OpenFirmware.

This code must initialize the hardware other than the CPU, and obtain the code for the next step, the boot loader. Modern computers provide several possibilities for the boot loader and the choice is normally set on the BIOS startup screen.

Boot Loader Phase

There are several possible types of boot loaders and ways for the BIOS to obtain them.

A. A boot loader stored in the first sector of a hard disk, the Master Boot Record, or MBR. This may be GRUB or LILO or yaboot or others.

B. A boot loader stored on some other storage device, such as a CDR or USB flash drive.

C. A boot loader which uses the network, such as the Pre-Execution Environment (PXE). This code is normally stored on a ROM on the networking card itself.

The need for the initial parts of the bootloader code on the first part of a storage medium explains why some hard drives are 'bootable' and others are not.

The job of the boot loader is to begin the next phase, loading the kernel and an initial ram disk filesystem.

Kernel Phase

The kernel is the core code of the operating system, providing access to hardware and other services. The bootloader starts the kernel running. To keep kernels to a reasonable size and permit separate modules for separate hardware, modern kernels also use a file system which is present in memory, called an 'initrd' for 'initial ram disk'.

Both the kernel file to load and the initial ram disk are normally specified as options to the boot loader.

The kernel launches the init script inside the initrd file system, which loads hardware drivers and finds the root partition.

System startup

After the kernel is running, the remainder of the operating system is brought online.

First the root partition and filesystem is located, checked and mounted. Next the init process is started, which runs the initialization scripts. These scripts involve different /etc/rc scripts and upstart events that eventually gives you a ready-to-use computer with a login screen.

Booting components

MBR (IBM-compatible PCs)

The master boot record is the first sector on a disk and contains in general a partition table for the disk and a simple boot loader. This simple boot loader will in most cases just look for an active partition on the same disk and jump to the boot sector on that partition. The boot sector will contain the real boot loader.

GRUB Boot loader

Because the GRUB boot loader provides menus of choices and can handle many different forms of hardware, it is larger than the code which can fit in a single MBR. It has 3 stages: stage 1 in the MBR, stage 1.5 in the remainder of the first cylinder of the disk, and stage 2 within in file on the disk.

Grub will find the /boot/grub/menu.lst which configures its interactive menu. The location of the menu.lst, as well as stage1.5 and stage2 files, is hard-coded into grub when it is installed to the boot sector. Grub locates and loads the kernel and the initrd, using BIOS calls and its build-in recognition of file systems (thanks to the different available stage1.5 parts). And finally boots the kernel.

In some cases, the operating system is split over several partitions (like /usr), and these partitions are mounted by the boot scripts as soon as they can be.

Conditions for success

  • First, the BIOS has to find the boot loader and this depends on your hardware's capabilities.
  • Second, the boot loader has to find the kernel and initrd. It will likely use BIOS calls, so this again depends on your BIOS.
  • Finally, the kernel will boot and must, with the help of the initrd, find the root partition

Finding the root partition

The root partition with the operating system can be somewhere completely different than the kernel, for instance on another drive or on a remote computer. In some cases the kernel may not find the root partition on the disk, because the initrd is missing the modules to access the partition. If this your case, rebuild your initrd to include the missing modules (see man mkinitramfs and man update-initramfs).

Other pages


CategoryBootAndPartition

Booting (last edited 2010-07-03 22:19:57 by nealmcb)