Linux boot process

From Free Geek Seattle

Booting Linux[edit]

The Linux kernel is capable of booting some systems on its own if it can somehow be loaded into RAM at boot time (for example, as a coreboot payload) , but this is generally not how it happens. Many devices are idiosyncratic in their boot requirements / process, and various technologies such as GRUB exist to mitigate this. This page will mostly focus on PC booting with some added information on other devices.

This article is a Stub. Please help improve this wiki by editing and expanding upon this article!

Before booting[edit]

PCs undergo a few steps before attempting to boot a kernel.

Android devices and other non-PC machines have different steps, so don't rely on this information if you're dealing with a non-PC machine.

POST[edit]

On power-on, a PC will perform a series of automated tests. The most user-visible part of this is the RAM-counting display that sometimes appears on-screen before the BIOS starts. If any of the tests fail, the computer will usually emit one of an array of beep codes and stop.

BIOS[edit]

BIOS is software provided by a third-party vendor that enumerates the hardware devices available to the system and provides this information to the operating system after the OS loads. BIOS also usually provides a set-up screen which allows the user to set certain hardware and boot-time options.

Boot process[edit]

If Linux does not boot directly from firmware, a "boot-loader" program is generally used. The two most common of these are GNU GRUB (Grand Unified Bootloader) and LiLO (Linux Loader). Also widely used in live CD images, network booting, and similar situations is SYSLINUX.

Android devices employ a bootloader which conditionally boots a "recovery" program or the main system. Each of the bootloader and the recovery software are stored in its own partition on the device's storage.

Boot loader[edit]

The boot loader is the first piece of code loaded from the storage device. On PCs the boot loader must live in the first few sectors of the disk, and needs to be able to run in real mode for machines that don't offer protected-mode access this early in the boot process (see Intel Processor Modes) The boot loader sometimes presents a menu of options which configure the chain loader, and, in turn, the booting kernel.

Chain loader[edit]

The chain loader replaces the boot loader's image in RAM with that of the kernel to be booted. After the kernel image is fully loaded it begins execution.

The chain loader is an optional step to support machines that can't otherwise support multiboot.

Booting the kernel[edit]

Housekeeping and setup[edit]

Device enumeration[edit]

Using ACPI[edit]
Using BIOS data[edit]
Using devicetree[edit]

sysfs[edit]

Rings[edit]

Setting up userspace[edit]

Passing control to init[edit]

Init[edit]

Differences between commonly-used Linux init programs[edit]

sysvinit and BSD init[edit]

systemd[edit]

Upstart[edit]

OpenRC[edit]

Starting initial services[edit]

getty[edit]

X and Session Managers[edit]

Mounting volumes[edit]