7.1. Following the Boot Sequence
Boot problems are easier to reason about when the stages are kept separate.
The firmware asks which device to start; the boot loader chooses a kernel and
a command line; the kernel and its initramfs find and mount the root
filesystem; systemd takes over and activates units until it reaches the
default target. A failure at each stage has a different symptom and a
different place to look. This section establishes what the current machine
did and which parts of that path are configurable.
7.1.1. Firmware, Boot Loader, Kernel, and Initramfs
The running kernel identifies the kernel package that was booted:
$ uname -r
6.12.117+deb13-amd64
The release string combines the upstream version, Debian's ABI suffix
(+deb13), and the architecture (-amd64); the package revision (-1)
appears in the package version instead. uname -r names the module
directory that must match the running kernel; after a kernel upgrade, the
old modules remain available for the old kernel, but they are never mixed
with the new one.
The kernel command line is the set of parameters the boot loader passed to
the kernel. It is available for the current boot at /proc/cmdline:
$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-6.12.117+deb13-amd64 root=UUID=be225267-eaf4-410c-9ffa-5cd32b221ce0 ro consoleblank=0 elevator=noop scsi_mod.use_blk_mq=Y net.ifnames=0 biosdevname=0
root=UUID=... tells the initramfs which filesystem to mount as /. The
ro flag mounts it read-only first; systemd remounts it read-write after
the filesystem check completes. consoleblank=0 stops the console from
blanking, and net.ifnames=0 biosdevname=0 disable predictable network
interface names on this image. The remaining parameters are discussed where
they are changed; an unknown parameter is normally left in /proc/cmdline
and ignored by the kernel, which is useful for testing but is not a
configuration mechanism.
The firmware interface is the first branch in the boot path. Linux exposes
EFI variables and firmware data under /sys/firmware/efi only when it was
started by UEFI firmware:
$ test -d /sys/firmware/efi && echo UEFI || echo BIOS
BIOS
This machine starts through legacy BIOS, so the directory does not exist and
the command prints BIOS. On a UEFI machine the same check prints UEFI and
the directory contains efivars, config_table, and related entries. The
distinction matters later: BIOS systems keep the first-stage boot code in the
disk's boot area, while UEFI systems keep boot loader files on a FAT EFI
System Partition and boot entries in NVRAM.
The boot loader on a BIOS system is usually GRUB, installed by the
grub-pc package. It reads /boot/grub/grub.cfg, displays a menu if the
timeout permits, and loads two files: the kernel image and an initial
ramdisk. The kernel image contains the core kernel; the initial ramdisk,
or initramfs, contains a small userland and the drivers needed to reach the
real root filesystem. The current initramfs contains an init program and
the storage modules for this machine:
# lsinitramfs /boot/initrd.img-$(uname -r) | grep -E '^init$|virtio_blk|ext4\.ko|conf/initramfs.conf'
usr/lib/modules/6.12.117+deb13-amd64/kernel/drivers/block/virtio_blk.ko.xz
usr/lib/modules/6.12.117+deb13-amd64/kernel/fs/ext4/ext4.ko.xz
conf/initramfs.conf
init
lsinitramfs lists the archive without unpacking it; the $(uname -r) in
the path selects the initramfs for the running kernel. The virtio_blk
module drives this virtual disk, ext4.ko understands the root filesystem,
and init is the first program the kernel executes. A different machine
would list different storage modules, but the structure is the same: enough
drivers to find /, plus the tools to mount it. Figure 7.1 shows the whole
sequence.
Figure 7.1. Conceptual view of the boot chain. The firmware selects a boot
loader, GRUB loads the kernel and initramfs, the initramfs mounts / and
hands control to systemd, and systemd activates targets until the default
target is reached.
The kernel ring buffer records the same transition from the kernel's point of
view. journalctl -b selects the current boot and -o short-monotonic
replaces wall-clock timestamps with seconds since boot, which makes the
ordering of early messages easier to read:
# journalctl -b -o short-monotonic --no-pager | head -n 18
[ 3.362356] trixie kernel: Linux version 6.12.117+deb13-amd64 (debian-kernel@lists.debian.org) (x86_64-linux-gnu-gcc-14 (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44) #1 SMP PREEMPT_DYNAMIC Debian 6.12.117-1 (2026-11-12)
[ 3.362402] trixie kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-6.12.117+deb13-amd64 root=UUID=be225267-eaf4-410c-9ffa-5cd32b221ce0 ro consoleblank=0 elevator=noop scsi_mod.use_blk_mq=Y net.ifnames=0 biosdevname=0
[ 3.362423] trixie kernel: BIOS-provided physical RAM map:
[ 3.362435] trixie kernel: BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[ 3.362446] trixie kernel: BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[ 3.362458] trixie kernel: BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[ 3.362479] trixie kernel: BIOS-e820: [mem 0x0000000000100000-0x000000003ffdafff] usable
[ 3.362491] trixie kernel: BIOS-e820: [mem 0x000000003ffdb000-0x000000003fffffff] reserved
[ 3.362502] trixie kernel: BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[ 3.362513] trixie kernel: BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[ 3.362525] trixie kernel: NX (Execute Disable) protection: active
[ 3.362551] trixie kernel: APIC: Static calls initialized
[ 3.362563] trixie kernel: SMBIOS 2.8 present.
[ 3.362576] trixie kernel: DMI: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 3.362595] trixie kernel: DMI: Memory slots populated: 1/1
[ 3.362607] trixie kernel: Hypervisor detected: KVM
[ 3.362621] trixie kernel: last_pfn = 0x3ffdb max_arch_pfn = 0x400000000
[ 3.362632] trixie kernel: kvm-clock: Using msrs 4b564d01 and 4b564d00
The monotonic timestamp here is the journal's, not the kernel's own printk
timestamp: the kernel ring buffer is imported after systemd starts, so the
first retained entry is stamped at about 3 seconds even though the kernel
itself begins at 0.000000 in dmesg. The Command line: line is a second
copy of /proc/cmdline and is the quickest way to confirm what the boot
loader actually passed. After the kernel has prepared
the root filesystem, systemd announces itself as PID 1:
# journalctl -b -o short-monotonic --no-pager | grep -m 6 "systemd\[1\]"
[ 3.466213] trixie systemd[1]: Inserted module 'autofs4'
[ 3.466233] trixie systemd[1]: systemd 257.13-1~deb13u1 running in system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +IPE +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +BTF -XKBCOMMON -UTMP +SYSVINIT +LIBARCHIVE)
[ 3.466250] trixie systemd[1]: Detected virtualization kvm.
[ 3.466264] trixie systemd[1]: Detected architecture x86-64.
[ 3.466278] trixie systemd[1]: Hostname set to <trixie>.
[ 3.466292] trixie systemd[1]: bpf-restrict-fs: LSM BPF program attached
The version line lists the build-time features compiled into systemd; it is
useful when a unit feature appears to be missing, but it is not a
configuration list. The more important fact is the transition: the kernel
has finished its early work, the initramfs has mounted the real root or
handed it to systemd, and systemd is now the parent of everything else.
systemd divides the boot into targets rather than runlevels. A target is a
unit that groups other units; activating a target pulls in its dependencies
in order. The active targets on a fully booted desktop show the chain that
was reached:
$ systemctl list-units --type=target --state=active --no-pager
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
getty.target loaded active active Login Prompts
graphical.target loaded active active Graphical Interface
local-fs-pre.target loaded active active Preparation for Local File Systems
local-fs.target loaded active active Local File Systems
multi-user.target loaded active active Multi-User System
network-online.target loaded active active Network is Online
network.target loaded active active Network
nss-user-lookup.target loaded active active User and Group Name Lookups
paths.target loaded active active Path Units
remote-fs.target loaded active active Remote File Systems
slices.target loaded active active Slice Units
sockets.target loaded active active Socket Units
swap.target loaded active active Swaps
sysinit.target loaded active active System Initialization
timers.target loaded active active Timer Units
Legend: LOAD → Reflects whether the unit definition was properly loaded.
ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
SUB → The low-level unit activation state, values depend on unit type.
16 loaded units listed.
The important names are sysinit.target (early setup, mounts, udev),
basic.target (sockets, timers, paths), multi-user.target (ordinary
services and login prompts), and graphical.target (the display manager).
local-fs.target and remote-fs.target are ordering points for mounts;
their failure has consequences covered in Section 7.6.2. Chapter 8 explains
how units are written and inspected; this chapter uses targets only as boot
milestones.
7.1.2. The Root Filesystem and the Transition to systemd
The kernel does not consult /etc/fstab to mount /; it uses the root=
value from the command line. The initramfs may parse other parameters (for
example, LVM or encryption options), assemble the device, and mount the
filesystem. Once / is available, the initramfs runs switch_root and
executes the real init, which on Debian is systemd. The mounted root
reports the source and options that resulted:
$ findmnt -no SOURCE,FSTYPE,OPTIONS /
/dev/vda1 ext4 rw,relatime,discard,errors=remount-ro
findmnt reads the kernel mount table and prints only the columns requested:
source, filesystem type, and mount options. The root is /dev/vda1 on
ext4, mounted read-write with discard and errors=remount-ro from
/etc/fstab; the kernel mounted it read-only first and systemd remounted
it according to the fstab entry. If the source here does not match the
root= value in /proc/cmdline, the initramfs used a different device than
the one you expected, which is a useful clue when a system boots the wrong
installation.
systemd-analyze measures how long the kernel and userspace took to reach
the target. On this GRUB/BIOS boot it reports only those two phases;
firmware and boot loader time are not included:
$ systemd-analyze time
Startup finished in 2.554s (kernel) + 6.134s (userspace) = 8.689s
graphical.target reached after 6.132s in userspace.
The two numbers are separate: the kernel time ends when systemd starts, and
the userspace time ends when the default target is reached. A large kernel
time points to kernel initialization, storage probing, or initramfs work; a
large userspace time points to a slow unit. systemd-analyze blame ranks units by
the time they consumed:
$ systemd-analyze blame | head -n 8
2.902s dev-vda1.device
2.364s apparmor.service
2.102s systemd-journal-flush.service
2.071s fwupd-refresh.service
2.011s systemd-binfmt.service
1.919s fwupd.service
1.377s proc-sys-fs-binfmt_misc.mount
977ms accounts-daemon.service
These are wall-clock durations, not CPU time, and units that wait on a device
or a network appear large even when they use little processor time. The
dev-vda1.device entry is the device unit for the root block device; it has
to become active before the units that depend on it can start. A slow disk or
a missing device shows up here.
Chapter 28 treats boot timing as one measurement among many; for boot
troubleshooting, the ordering in journalctl -b is usually more informative
than the ranking.
The transition is visible in the journal because systemd logs its own
startup and the units it activates. A boot that stops before
multi-user.target will have the early messages but not the later ones; a
boot that reaches graphical.target but leaves a service failed will show
the failure after the target is reached. The --no-pager option keeps the
output in the terminal instead of opening less, which is useful when
capturing a transcript for a bug report or a change record.
7.1.3. Boot Targets and the Default System State
The default target is the target systemd starts when no other target is
requested. It is stored as a symlink, so the effective value can be read in
two ways:
$ systemctl get-default
graphical.target
$ readlink -f /etc/systemd/system/default.target
/usr/lib/systemd/system/graphical.target
get-default resolves the symlink and prints the target name; readlink -f
shows the file the link ultimately points to. The symlink lives in
/etc/systemd/system, so a local change survives package upgrades, while the
target definitions themselves live under /usr/lib/systemd/system. This is
the same split used for other systemd configuration: local policy in /etc,
vendor defaults in /usr/lib.
Targets can be activated without changing the default. isolate stops the
units that are not wanted by the requested target and starts the ones that
are; it is a temporary state change, not a persistent one:
# systemctl isolate multi-user.target
The command normally prints nothing. On a desktop, graphical.target is now
inactive and the display manager has been stopped, while multi-user.target
and its services, including SSH, remain:
$ systemctl is-active graphical.target
inactive
is-active exits nonzero when the unit is not active, which is why the
command's status is 3 here. To return to the graphical session, isolate the
graphical target again:
# systemctl isolate graphical.target
$ systemctl is-active graphical.target
active
isolate is useful for testing a service without a reboot, but it is not a
safe way to stop a remote system: isolating a target that does not include
ssh.service will terminate the session you are using. If the goal is to
make the change persistent, use set-default instead:
# systemctl set-default multi-user.target
Removed '/etc/systemd/system/default.target'.
Created symlink '/etc/systemd/system/default.target' → '/usr/lib/systemd/system/multi-user.target'.
The messages are written to standard error, so a script that captures only
standard output will miss them; the exit status is what matters. The default
is now multi-user.target, and a reboot would stop at a text login instead
of starting the display manager. Restore the graphical default when the
experiment is over:
# systemctl set-default graphical.target
Removed '/etc/systemd/system/default.target'.
Created symlink '/etc/systemd/system/default.target' → '/usr/lib/systemd/system/graphical.target'.
The common targets and their purposes are summarized in Table 7.1.
| Target | What it provides | Typical use |
|---|---|---|
poweroff.target |
Shuts the system down. | systemctl isolate poweroff.target or systemctl poweroff. |
rescue.target |
Single-user mode with most services stopped; root shell on the console. | Repairing filesystems, accounts, or configuration that must not race with services. |
emergency.target |
Minimal environment with / mounted read-only and almost nothing else. |
Last-resort repair when rescue.target cannot start. |
multi-user.target |
Ordinary services, gettys, and remote access without a graphical session. | Servers and text-mode administration. |
graphical.target |
multi-user.target plus the display manager and desktop. |
Workstations with a graphical login. |
Changing the default target is a persistent change and should be recorded in
the system's configuration history. On a server, multi-user.target is the
normal choice; on a workstation, graphical.target is. Neither target
controls which services are enabled: a service can be enabled and still not
belong to a target, or can be pulled in by a dependency even when it is not
enabled. Chapter 8 covers that distinction.