Estimated time: 40 minutes.
Analyze the Linux boot process: measure boot time and identify the service that slows down boot with systemd-analyze (blame / critical-chain / --failed),
explain the 5 boot layers (firmware → GRUB → kernel → initramfs → systemd), and propose ways to fix a slow boot.
The IP addresses in this exercise are illustrative addresses from the range reserved for documentation (RFC 5737): dattqh-nat = 192.0.2.21, dattqh-client = 192.0.2.22; when you do the exercise, replace them with the real IPs of your machines.
The standard procedure for finding a slow boot is systemd-analyze → blame → critical-chain → --failed (systemd-analyze(1)).
# On dattqh-nat (192.0.2.21)
systemd-analyze
systemd-analyze blame | head -10
systemd-analyze critical-chain | head -20
systemctl --failed
sudo journalctl -b -u systemd-networkd-wait-online --no-pager | tail
Notes: Observations: systemd-analyze → 4.065s (kernel) + 2min 2.993s (userspace).
Top of blame = 2min 131ms systemd-networkd-wait-online.service. systemctl --failed lists this unit as FAILED. journal: Timeout occurred while waiting for network connectivity.
Same image, the dattqh-client VM boots in 8.9s.
# On dattqh-client (192.0.2.22)
systemd-analyze
systemd-analyze blame | head -6
systemctl --failed
sudo journalctl -b -u systemd-networkd-wait-online --no-pager | tail -3
Notes: Observations: systemd-analyze → 4.322s + 4.663s = 8.985s. blame: 1.140s systemd-networkd-wait-online.service (finished quickly). systemctl --failed is empty. journal: Finished systemd-networkd-wait-online.service (~1s, no timeout).
Understanding boot is not just measuring time; it also means reading the current state of each layer: kernel cmdline, GRUB, initramfs, default.target.
# On 171 — read each layer (read-only)
cat /proc/cmdline
ps -p 1 -o pid,comm
findmnt /
lsinitramfs /boot/initrd.img-$(uname -r) | grep -iE 'lvm|virtio' | head
systemctl get-default
# HOW TO FIX wait-online (for reference — do not run on the lab VM):
# sudo nano /etc/netplan/50-cloud-init.yaml -> add 'optional: true' under ens160
# sudo netplan try && sudo netplan apply
# or remove 'dhcp4: true' if you only use a static address.
Notes: Observations: cat /proc/cmdline → BOOT_IMAGE=/vmlinuz-6.8.0-31-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro. ps -p 1 → 1 systemd. findmnt / → root on /dev/mapper/ubuntu--vg-ubuntu--lv. systemctl get-default → graphical.target.
systemd-analyze: userspace takes 2 minutes; blame lists systemd-networkd-wait-online first.
systemctl --failed + journal: wait-online timed out after 120s → status=1/FAILURE.
Same image: boot takes 9s, wait-online finishes in 1.1s, no unit is FAILED → the culprit is a hung service, not the hardware.