How systemd-boot Bridges UEFI to the Linux Kernel: A Complete Walkthrough
This article explains the full boot sequence from power‑on through UEFI firmware, the boot manager, and the systemd-boot loader, detailing how PE32+ UEFI applications, BootOrder variables, and EFI_BOOT_SERVICES functions load and start the Linux kernel.
The article follows a panoramic diagram to explain every step from powering on a computer to the execution of the first line of Linux kernel code.
UEFI Firmware and Boot Manager
When a PC powers up, the embedded UEFI firmware starts, initializing hardware and invoking its internal boot manager. The boot manager searches for a UEFI application—a PE32+ format executable defined by the UEFI specification. Because the Linux kernel can also be compiled as a PE32+ image, it is technically executable directly by UEFI, though a boot loader is usually inserted for flexibility.
Why Use a Boot Loader?
Adding a boot loader (e.g., GRUB or systemd-boot) allows easy configuration of the initrd image and kernel parameters. The article recommends systemd-boot for everyday use because it is simpler to configure and is bundled with systemd, which is present on most modern Linux distributions.
UEFI Boot Manager Logic
The UEFI boot manager reads the BootOrder variable, which stores a list of identifiers such as Boot0004, Boot0003, etc. Each identifier points to another UEFI variable that contains the file path of the executable (e.g., /boot/EFI/systemd/systemd-bootx64.efi). The manager loads the selected program with EFI_BOOT_SERVICES.LoadImage() and starts it with EFI_BOOT_SERVICES.StartImage(). Successful loading means the program’s entry point is invoked.
On a real machine you can inspect these variables with efibootmgr and modify them with efivar: efibootmgr – lists, adds, removes, or changes UEFI boot entries. efivar – reads or writes any UEFI variable directly.
systemd-boot Startup Flow
The entry point of systemd-boot is the efi_main function. It performs the following actions:
Scans /boot/loader/entries/ for .conf files, each representing a boot entry.
Reads /boot/loader/loader.conf to determine the default entry (e.g., nixos-generation-292.conf).
Loads the initrd specified in the selected entry into memory and binds it to a fixed UEFI device path.
Uses EFI_BOOT_SERVICES.LoadImage() to load the kernel image referenced by the entry.
Copies the kernel command‑line parameters from the entry into the kernel image’s metadata.
Calls EFI_BOOT_SERVICES.StartImage() to hand control to the kernel.
After StartImage() succeeds, control transfers to the Linux kernel’s UEFI entry point, and systemd-boot’s role ends. The process mirrors the direct UEFI‑to‑kernel launch, showing that systemd-boot can start any UEFI application, not just Linux kernels.
In summary, the article maps the entire boot path—from UEFI firmware initialization, through the boot manager’s variable handling, to systemd-boot’s loading of initrd and kernel—providing a clear, step‑by‑step view of how a Linux system begins execution.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
