Booting the system
What happens between pressing the power button and getting a login prompt: firmware, boot loader, kernel, initramfs, then the first userspace process — and where each stage writes down what it did.
Lesson 2 of 3 in objective 101. System architecture, part of LPIC-1 Exam 101-500.
The chain, stage by stage
Firmware (BIOS or UEFI) tests the hardware and hands control to a boot loader. On a BIOS machine that loader lives in the first sector of the disk, the MBR, which has 512 bytes to work with — enough for a stub that loads the rest. On a UEFI machine the firmware reads a real file from the EFI system partition instead, which is why UEFI boot loaders are easier to inspect and to break by deleting a file. UEFI also keeps its own menu of those loaders in NVRAM rather than on the disk — one BootXXXX variable per entry, plus a BootOrder saying which is tried first — and efibootmgr is what reads and rewrites that menu from a running system, so efibootmgr -v lists the entries and efibootmgr -o reorders them without going near the firmware setup screen.
The boot loader loads two things: the kernel and an initramfs. The initramfs is a small compressed root filesystem held in memory, and it exists to solve a chicken-and-egg problem — the drivers needed to read the real root filesystem (a RAID controller, an LVM volume, an encrypted disk) may themselves live on that filesystem. The initramfs carries just enough to mount the real root, then hands over to it.
The kernel then starts exactly one userspace process, PID 1, and everything else on the machine is a descendant of it. On most current distributions that is systemd; older ones use SysVinit, and a few use Upstart. Booting with init=/bin/bash as a kernel parameter replaces PID 1 with a shell, which is the classic way back into a system whose root password is lost.
Rebuilding the initramfs when the storage under root changes
An initramfs is built for one kernel on one machine and carries only the modules that machine needed at the time. Move the root filesystem onto an LVM logical volume, onto a RAID array, or behind LUKS, and the image that worked yesterday no longer contains the code to reach it: the kernel starts normally, the early userspace finds nothing it can mount as root, and the boot stops in an emergency shell complaining that there is no live root filesystem. Correcting root= does not help, because the kernel is not lost — it is unequipped. The image has to be regenerated.
The command for that differs by family, and both spellings are asked. Red Hat family systems use dracut: dracut -f overwrites the image for the running kernel in place, dracut -f --kver 6.1.0-18 names another one, and lsinitrd lists what ended up inside so you can check the device-mapper modules are actually there. Debian family systems use update-initramfs, where -u updates the image for the running kernel and -u -k all does every installed kernel; mkinitramfs is the lower-level tool it drives, and mkinitrd is the older name still met on SUSE. Reaching for the other family's tool is the wrong answer even when the reasoning behind it was right.
Red Hat family: rebuild for the running kerneldracut -flsinitrd | grep -c dm-mod1Debian family: the same job under another nameupdate-initramfs -u -k allupdate-initramfs: Generating /boot/initrd.img-6.1.0-18
Changing the kernel command line for one boot
A machine that hangs during boot has to be argued with before anything is running to argue with, and the place to do it is the boot loader menu. In GRUB, e opens the selected entry for editing; you append to the line beginning linux and press Ctrl-X or F10 to boot with the change. Nothing is written to disk, so the next boot is the old one again — which is what you want while you are still guessing.
Two parameters carry most of the recovery work. systemd.unit= names the target to boot into, so systemd.unit=rescue.target reaches maintenance without touching the default, and systemd.unit=emergency.target goes further down when even rescue will not come up. The older spellings single, 1 and init=/bin/bash do a similar job on a SysVinit machine, and systemd still honours them. systemd.mask= switches off one hanging unit for a boot without disabling it permanently.
Everything the running kernel was actually given is readable afterwards in /proc/cmdline, which is the fastest way to confirm whether the parameter you typed at the menu made it through.
at the menu: press e, then edit the line starting linuxlinux /vmlinuz-6.1.0-18 root=UUID=1c3f... ro quietappend the target, then Ctrl-X to bootlinux /vmlinuz-6.1.0-18 root=UUID=1c3f... systemd.unit=rescue.targetcat /proc/cmdlineBOOT_IMAGE=/vmlinuz-6.1.0-18 root=UUID=1c3f... rosystemd.unit=rescue.target
Reading what the boot said
The kernel writes to a fixed-size ring buffer as it starts, and dmesg prints it. On a systemd machine journalctl -k prints the same thing from the journal and, unlike dmesg, journalctl -b -1 can show the boot before this one — which is what you want when the question is why the machine rebooted.
Userspace logging lands in /var/log. On systemd systems most of it is in the binary journal, read with journalctl; on others, and often on both, plain text arrives in /var/log/messages or /var/log/syslog.
A boot that succeeded but took two minutes is a different question, and systemd-analyze is what answers it. On its own it prints how long the firmware, the loader, the kernel and userspace each took. systemd-analyze blame prints one line per unit ranked by its own initialisation time, longest first, which is the list a question describing a slow boot is asking for. systemd-analyze critical-chain prints something that looks similar and is not: the chain of units that actually held the target up, which is usually shorter than the blame list because most of the slow units were starting in parallel and delayed nothing.
Worth carrying in
- dmesg
- The kernel ring buffer. Cleared on reboot; -T adds human-readable timestamps.
- journalctl -k
- Kernel messages from the journal. -b -1 for the previous boot.
- /proc/cmdline
- The kernel parameters this running kernel was given.
- initramfs
- In-memory root filesystem carrying the drivers needed to reach the real one.
- init=
- Kernel parameter naming the first userspace process.
init=/bin/bashis the recovery trick. - root=
- Kernel parameter naming the real root filesystem, usually by UUID.
- systemd.unit=
- Kernel parameter naming the target to boot into.
systemd.unit=rescue.targetfor maintenance. - efibootmgr -v
- List the firmware boot entries held in NVRAM.
-osets the order,-ccreates one,-Bdeletes one. - dracut -f
- Rebuild the initramfs on a Red Hat family system.
lsinitrdlists what is inside one. - update-initramfs -u
- The Debian family equivalent.
-k allrebuilds for every installed kernel. - systemd-analyze blame
- Units ranked by initialisation time.
critical-chainshows what actually delayed the target.
What the exam does with this
- Order matters and is asked directly: firmware, boot loader, kernel, initramfs, init/systemd, then services.
dmesgshows the kernel ring buffer only. Anything a service logged is not in it.- Changing what sits under the root filesystem means rebuilding the initramfs:
dracut -fon Red Hat family systems,update-initramfs -uon Debian ones. A question that names the distribution is testing which. - The firmware boot order and the GRUB menu are two different menus.
efibootmgrreorders the first; regeneratinggrub.cfgchanges the second. - Editing the entry at the GRUB menu changes ONE boot and writes nothing. A question that says "for this boot only" is asking for that, not for an edit to
/etc/default/grub. - Know why an initramfs exists at all — "the drivers to read root may be on root" is the answer being tested.
- Objective
- 101. System architecture
- Share of the exam
- 13.33% (the whole objective)
- Questions in this lesson
- 15
- Signed for by a person
- 0
Partly checked. None of the 15 questions here has been read against the cited source by a person. 15 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.
Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.
How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.
Drill this lesson
A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.
Questions in this lesson
- On a traditional BIOS PC, the firmware has completed its power-on self test and selected the hard disk as the boot device. What happens next? machine-checked
- A systemd-based machine fails during a normal boot because a service hangs. At the boot loader menu you want to edit the kernel command line for this one boot so the system comes up in single-user rescue mode instead. Which parameter do you append? machine-checked
- A systemd server with a persistent journal rebooted overnight. You need the log messages from the boot that ended in that reboot, not from the current boot. Which command shows them? machine-checked
- Which THREE of the following have been used on Linux as the init system, that is the first userspace process the kernel starts as PID 1? machine-checked
- A UEFI machine has two installed distributions. The firmware currently starts the older one first, and you want the newly installed entry to be tried first from now on, without touching the firmware setup screen. Which tool changes the boot order? machine-checked
- You have added GRUB_TIMEOUT=10 and a kernel argument to /etc/default/grub on a GRUB 2 system. The next boot ignores both. What was missed? machine-checked
- On a Red Hat family server you moved the root filesystem onto an LVM logical volume and updated the kernel's root= argument accordingly. The next boot stops in an emergency shell with 'unable to find a live root filesystem'. Which command addresses the cause? machine-checked
- dmesg output prefixes every line with a figure such as [ 12.884301 ], and you need to correlate a disk error with an incident that happened at a known wall-clock time. Which option prints dates and times instead? machine-checked
- A colleague added a kernel argument at the boot loader menu and you want to confirm that the running kernel actually received it. Type the full path of the virtual file that shows the command line the running kernel was started with. machine-checked
- Which sequence correctly describes a modern Linux boot from the moment the firmware hands control to the boot loader? machine-checked
- After an unexplained reboot you run `journalctl -b -1` and are told that no persistent journal was found, although the current boot's messages are readable. What makes the previous boot's messages available in future? machine-checked
- Select the THREE items that a typical Linux installation keeps in /boot. machine-checked
- A systemd server now takes almost two minutes to reach its default target and you want a list of every unit ranked by how long it took to initialise. Which command produces it? machine-checked
- Select the THREE true statements about the initramfs. machine-checked
- A cloned virtual machine panics with 'VFS: Unable to mount root fs on unknown-block(0,0)' because the disk it was cloned from had a different device name. Which kernel parameter tells the kernel which filesystem to mount as root? machine-checked
The rest of objective 101
- Determining and configuring hardware settings
- Booting the system — you are here
- Boot targets, shutting down and rebooting