InterspaceBaza znanjaTehnični člankiUčenjeHow does Linux boot?
UČENJE
10-Okt-2025
How does Linux boot?
Ta vsebina je na voljo samo v angleščini.

1.BIOS: The Traditional Approach

The Basic Input/Output System (BIOS) has been the standard firmware interface for decades. When BIOS takes control, it initializes only the most critical hardware components: the CPU, RAM, keyboard, and display. It then performs the Power-On Self-Test (POST), systematically checking the functionality of major components including memory, processor, graphics, and storage devices. If POST detects a hardware fault, it signals an error through beep codes or on-screen messages, preventing further boot progression.

After successful hardware verification, BIOS searches connected storage devices in a configurable boot order, looking for the Master Boot Record (MBR) — a special 512-byte sector at the beginning of a bootable disk that contains the first-stage bootloader. The MBR partitioning scheme supports disks up to 2 TB and allows a maximum of four primary partitions. For larger disks or more flexible partitioning, the GUID Partition Table (GPT) is required, which is natively supported by UEFI rather than BIOS.

2.UEFI: The Modern Standard

UEFI (Unified Extensible Firmware Interface) represents a complete reimagining of system firmware. Unlike BIOS, which operates in 16-bit real mode with severe limitations, UEFI is a sophisticated environment with filesystem awareness. It can directly read the EFI System Partition (ESP) — typically a FAT32 partition containing bootloader executables—eliminating the need for the tiny bootstrap code required by MBR.

UEFI brings substantial advantages: support for the GUID Partition Table (GPT), which handles disks exceeding 2TB and allows unlimited partitions; significantly faster boot times through better hardware initialization; Secure Boot capabilities that verify bootloader signatures; and often a graphical interface with mouse support. Many Linux distributions use a "shim" bootloader to navigate Secure Boot requirements without requiring users to modify UEFI firmware keys

This firmware stage is foundational—it prepares the processor and memory subsystems, verifies hardware integrity, and locates the bootloader that will load the operating system.

3.Stage 1: The Bootloader Takes Control

Once firmware identifies a bootable device, it transfers execution to the bootloader—a small but critical program responsible for loading the Linux kernel into memory and preparing the system for operating system initialization.

3.1.Bootloader Responsibilities

The bootloader performs several essential functions. It locates and loads one or more kernel images from disk, loads an initial RAM filesystem (initrd or initramfs) containing essential drivers and utilities needed before the real root filesystem becomes accessible, and passes kernel parameters that control boot behavior—options like ro for read-only root mounting, quiet to suppress verbose output, nomodeset to disable kernel graphics drivers, or init=/bin/bash for emergency recovery.

Modern bootloaders also provide user interaction capabilities, allowing you to select different kernels, operating systems, or boot into recovery modes.

3.2.Popular Bootloader Options

GRUB2 (Grand Unified Bootloader) has become the de facto standard for most Linux distributions. It supports multiboot environments, presents graphical menus, handles complex configurations, and works with both BIOS and UEFI firmware.

SYSLINUX and ISOLINUX are lightweight alternatives commonly used for live USB drives and installation media, offering simplicity over features.

systemd-boot provides a minimalistic UEFI-only bootloader tightly integrated with systemd-based distributions, favoring simplicity and fast boot times.

In embedded systems, Das U-Boot dominates, supporting ARM, MIPS, and numerous other architectures with features tailored to resource-constrained devices.

Some cutting-edge systems use coreboot, which replaces traditional BIOS/UEFI entirely and can integrate kernel loading directly into the firmware.

3.3.GRUB2 Boot Stages

On BIOS systems, GRUB2 operates through multiple stages due to space constraints. Stage 1, residing in the 446 bytes of executable code within the MBR, locates and loads Stage 1.5 (core.img), which contains filesystem drivers. This allows GRUB to understand ext4, XFS, Btrfs, and other filesystems. Stage 2 then loads the full GRUB configuration from /boot/grub/grub.cfg, presents the boot menu, and loads the selected kernel and initramfs into memory before transferring control.

UEFI systems simplify this process considerably. GRUB exists as a single EFI executable stored on the ESP (typically at /boot/efi/EFI/), eliminating the multi-stage complexity entirely.

4.Stage 2: Kernel Initialization and Hardware Detection

With the kernel loaded into memory, the bootloader transfers control, and Linux itself begins execution. The kernel image—usually named vmlinuz or bzImage—is compressed to save disk space and must first decompress itself before execution can begin.

4.1.Core Kernel Initialization

The kernel immediately begins detecting and configuring hardware. It identifies the CPU type and capabilities (number of cores, supported instruction sets, virtualization features), establishes the memory layout, and initializes essential subsystems including the memory management unit, interrupt controllers, and the process scheduler.

At this point, the kernel is operating in a minimal environment without access to most hardware. This is where the initial RAM filesystem becomes critical.

4.2.The Role of initramfs

The initramfs (or older initrd) is a compressed archive containing a minimal root filesystem with essential kernel modules and utilities. The kernel extracts this archive into a temporary RAM-based filesystem and executes the init script found within.

This temporary environment serves a vital purpose: it contains the drivers needed to access your actual root filesystem, which might reside on complex storage configurations. The initramfs typically includes kernel modules for various storage controllers (SATA, NVMe, SAS, hardware RAID), filesystem drivers (ext4, XFS, Btrfs, F2FS), device mapper support for LVM (Logical Volume Management), encryption support for LUKS-encrypted volumes, and software RAID (mdadm) for managing RAID arrays.

4.3.Locating and Mounting the Root Filesystem

Using the modules and utilities in initramfs, the kernel locates the root partition specified in the bootloader's kernel parameters (typically as root=/dev/sda1 or root=UUID=...). For encrypted systems, the initramfs prompts for passphrases to unlock LUKS volumes. For LVM or RAID configurations, it assembles the necessary logical volumes or arrays.

The root filesystem is initially mounted read-only, allowing filesystem consistency checks (fsck) to run safely. Once verified, the kernel performs a switch_root operation, making the real root filesystem the new root and discarding the temporary initramfs environment.

5.Stage 5: The Init System Brings Up User Space

With the root filesystem mounted, the kernel starts the first user-space process: init, which always receives Process ID (PID) 1. This process is fundamentally different from all others—it never terminates, serves as the ancestor of all subsequent processes, and is responsible for transforming the minimal kernel environment into a fully functional system.

5.1.Core Init Responsibilities

The init process handles several critical functions that define the system's operational state.

5.1.1.Bootstrapping User Space

Init represents the transition from kernel space to user space. It finalizes the boot sequence by mounting remaining filesystems listed in /etc/fstab, establishing system-wide environment variables from files like /etc/environment that every other process inherits, and remounting the root filesystem as read-write to allow normal operations.

5.1.2.Service and Process Management

Init starts essential background services (daemons) in a specific order, respecting dependencies. This includes critical services like udev for dynamic device management, system logging facilities, networking subsystems, time synchronization, and scheduled task managers like cron.

It organizes the system into different operational states—traditionally called "runlevels" in SysVinit or "targets" in systemd—that determine which services are active. Common targets include rescue mode (single-user, minimal services), multi-user mode (full networking and services, text console), and graphical mode (multi-user with display manager).

5.1.3.Process Supervision

Init plays a special role as the system's process "reaper." When any parent process terminates before its children, init automatically adopts these orphaned processes. When they eventually exit, init collects their exit status, preventing "zombie" processes from accumulating in the process table. Init can also monitor critical services and automatically restart them if they fail unexpectedly.

5.1.4.System Shutdown Management

When shutdown or reboot is initiated, init orchestrates graceful termination. It sends SIGTERM signals to all processes, allowing them time to close files and clean up resources, follows with SIGKILL for any processes that don't respond, ensures all filesystems are properly unmounted to prevent corruption, and finally signals the kernel to halt or reboot.

5.2.Init System Implementations

Traditional Unix systems used SysVinit, which executes shell scripts sequentially from directories like /etc/rc.d/ or /etc/init.d/. While simple and predictable, this sequential approach resulted in slow boot times.

systemd has become the standard init system for most major distributions including Ubuntu, Fedora, Debian, Arch, and RHEL. It revolutionizes the boot process through parallel service startup, on-demand activation, dependency resolution, and unified logging through journald.

systemd uses "unit files" stored in /etc/systemd/system/ and /usr/lib/systemd/system/.

Alternative init systems include OpenRC, runit, and the now-deprecated Upstart.

6.Stage 6-7: System Services and Target Transition

As init processes its configuration, it progressively brings up system services and transitions through targets or runlevels.

Essential services start first: udev creates device nodes in /dev/ as hardware is detected, system logging begins capturing messages, network interfaces are configured (either through NetworkManager, systemd-networkd, or traditional ifupdown), time synchronization services like chronyd or systemd-timesyncd ensure accurate system time, and D-Bus provides inter-process communication for desktop services.

The system then transitions to its configured default target. On servers, this is typically multi-user.target, which provides full networking and services but no graphical interface. On desktop systems, graphical.target additionally starts the display manager

7.Stage 8-9: Login Interface and User Session

With services running, the system presents its login interface based on the target reached.

Command-line login: In multi-user mode, getty processes spawn on virtual terminals. After authentication through PAM (Pluggable Authentication Modules), the shell starts—bash, zsh, fish, or others—reading its configuration files (.bashrc, .zshrc, .profile) to set up your environment.

Graphical login: In graphical mode, a display manager starts — GDM (GNOME Display Manager), SDDM (Simple Desktop Display Manager), LightDM, or others. After login, the display manager launches your selected desktop environment (GNOME, KDE Plasma, XFCE, Cinnamon), which starts window managers, panels, desktop services, and user-specific applications.

8.The Complete Boot Timeline

StageComponentKey ActionsResult
0BIOS/UEFIInitialize hardware, POST checks, locate boot deviceBoot device identified
1Bootloader (GRUB2)Load kernel and initramfs, pass parametersKernel in memory
2KernelDecompress, initialize CPU/memory, detect hardwareKernel running
3initramfsLoad storage/filesystem drivers, locate root partitionRoot filesystem accessible
4Root MountMount root filesystem, run fsck if neededStable root available
5Init (PID 1)Start user space, become process supervisorSystem initialization begins
6ServicesStart daemons, mount filesystems, configure networkCore services running
7TargetTransition to multi-user or graphical modeSystem operational state
8LoginPresent getty or display managerAuthentication available
9SessionStart shell or desktop environmentUser environment ready

9.Troubleshooting and Inspection Tools

Linux provides comprehensive tools for examining and troubleshooting the boot process. The journalctl -b command displays all logs from the current boot, while journalctl -b -1 shows logs from the previous boot—invaluable after a failed boot. The dmesg command reveals kernel messages including hardware detection and driver loading.

For systemd systems, systemd-analyze shows total boot time broken down by firmware, bootloader, kernel, and userspace phases. The systemd-analyze blame command lists services sorted by initialization time, helping identify bottlenecks. The systemd-analyze critical-chain command visualizes the dependency chain that determines boot order.

Configuration files live in several locations: GRUB configuration in /boot/grub/grub.cfg (auto-generated from /etc/default/grub and files in /etc/grub.d/), kernel parameters visible in /proc/cmdline, systemd unit files in /etc/systemd/system/ (user modifications) and /usr/lib/systemd/system/ (distribution defaults), and filesystem mount information in /etc/fstab.

10.Common Boot Parameters

Kernel parameters passed by the bootloader control system behavior. Understanding these helps with troubleshooting and customization:

  • quiet suppresses most kernel messages for a cleaner boot screen, while removing it enables verbose output
  • splash displays a graphical boot splash screen
  • single or systemd.unit=rescue.target boots into single-user rescue mode with minimal services
  • nomodeset disables kernel mode setting, useful when graphics drivers cause problems
  • init=/bin/bash boots directly to a root shell, bypassing init entirely for emergency recovery
  • rd.break drops to a shell during initramfs processing before mounting the root filesystem
  • ro mounts the root filesystem read-only, while rw mounts it read-write

11.Embedded and Special Configurations

Embedded Linux systems follow the same fundamental boot sequence but with specialized components. They often use minimal bootloaders like U-Boot tailored to specific SoCs, employ custom kernel configurations stripped of unnecessary drivers to minimize footprint, utilize buildroot or Yocto-generated initramfs images, and implement lightweight init systems like BusyBox init or runit for resource efficiency.

Some systems use additional boot stages, particularly when booting from complex storage like network filesystems, where an additional network initialization phase loads before the root filesystem mount.

12.Conclusion

The Linux boot process represents a carefully orchestrated sequence of handoffs, with each component preparing the environment for the next. From the moment power is applied, through firmware initialization, bootloader execution, kernel startup, and init system activation, each stage has clearly defined responsibilities and exit conditions.

This modular design provides remarkable flexibility—you can replace the bootloader, customize the kernel, choose your init system, and configure services, all while maintaining system stability. Understanding this process empowers you to troubleshoot boot failures, optimize startup times, customize system behavior, and appreciate the sophisticated engineering that transforms electrical power into a functioning computing environment in mere seconds.

The next time you press the power button, you'll recognize the intricate dance of firmware, bootloader, kernel, and init system working in harmony to bring your Linux system to life.

Povezana vsebina
Dokumentacija
Oblak
Komunikacije
Gostovanje
My Interspace
Tehnični članki
Vodniki
Učenje
Novice
Zadnje novice
Zadnji dogodki
Povezani produkti
Elastični oblačni VPS
Elastic Cloud VPS je virtualni stroj, ki deluje na naprednih oblačnih in omrežnih tehnologijah ter ponuja superiorne prednosti pred tradicionalnim VPS gostovanjem po izjemnem razmerju med ceno in zmogljivostjo. Namestitev OS in aplikacij v samo 1 minuti. Geo-redundantne varnostne kopije z enim klikom, posnetki in obnovitev po nesreči. Procesorji nove generacije AMD EPYC, ultra hitro NVMe shranjevanje, dedikovane povezave in brezplačno privatno omrežje.
Premium internetni dostop
Internetni dostop najvišjega razreda za profesionalne potrebe. Vrhunska točka-točka optična povezava, simetrična hitrost prenosa navzdol/navzgor, neomejen promet, SLA 99,9% in statični IP. Neposredne povezave do najboljših globalnih ponudnikov prve stopnje. Naša omrežna arhitektura je skrbno zasnovana za zagotavljanje najvišje kakovosti povezav do katerekoli destinacije po svetu, s hitrostmi prenosa brez primere in večnivojsko redundanco.
Namenski strežniki
Namenski strežniki na vrhunski strojni opremi priznanih proizvajalcev strežnikov. Gostujejo v naših podatkovnih centrih, kar nam omogoča popoln nadzor pri zagotavljanju delovanja 24/7. Izbira primarnih podatkovnih centrov in podatkovnega centra za obnovo po nesreči, ki se nahaja na varni razdalji. Možnosti nadzora napajanja (ponovni zagon, izklop/vklop) in brezplačen KVM-over-IP na voljo 24/7 z enim klikom, vključno s podporo za oddaljeni zagon/namestitev lastnih ISO datotek.


Naša spletna stran uporablja piškotke. Z nadaljnjo uporabo naše spletne strani soglašate z uporabo piškotkov in se strinjate z našimi Pogoji uporabe. Razumem