Linux boot process

From Free Geek Seattle
Revision as of 17:50, 22 February 2015 by Koanhead (talk | contribs) (Created page with "=Booting Linux= 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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Booting Linux

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.

Before booting

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

POST

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

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

Boot loader

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

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

Housekeeping and setup

Device enumeration

Using ACPI
Using BIOS data
Using devicetree

sysfs

Rings

Setting up userspace

Passing control to init

Init

Differences between commonly-used Linux init programs

sysvinit and BSD init

systemd

Upstart

OpenRC

Starting initial services

getty

X and Session Managers

Mounting volumes