Lesson 9 of 9 · 27m
Debugging Boot Problems and Failed Units Without Guesswork
A disciplined incident workflow: interpret systemctl output, reconstruct boot history, use debug shells safely, and fix root causes rather than masking them.
When a machine does not come back after reboot, panic produces bad decisions. systemd gives enough instrumentation to reconstruct what happened — if you work in the right order. The goal is not merely a login prompt; it is knowing which assumption broke.
Start with state, not folklore
systemctl --failed
systemctl status multi-user.target
journalctl -b -p err..alert
systemd-analyze critical-chainThen inspect the specific unit:
systemctl status app.service
journalctl -u app.service -b --no-pager
systemctl show app.service -p ExecMainStatus -p Result -p NRestartsImportant fields are Result (exit-code, signal, timeout, start-limit-hit), ExecMainStatus, and NRestarts. They distinguish a single failed start from a crash loop.
Exit code 1 usually means the application returned generic failure. 203/EXEC means systemd could not execute the binary at all: missing file, bad interpreter, permission problem, or incompatible architecture. Those are different incidents.
Use the previous boot
journalctl --list-boots
journalctl -b -1 -e --no-pager
journalctl -b -1 -p err..alert-b -1 means the boot before the current one. Look near the end first: kernel errors, filesystem remounts, OOM kills, watchdog resets. Then move backward. Units often fail because a filesystem never mounted, not because the units themselves are broken.
Emergency and debug shells
Kernel command-line options can alter boot temporarily:
systemd.unit=rescue.target
systemd.unit=emergency.target
systemd.debug_shell=1rescue.target gives a minimal administrative environment. emergency.target is smaller still. systemd.debug_shell=1 starts a root shell on tty9 very early — powerful, dangerous, and inappropriate to leave enabled.
For a broken service, systemctl edit --runtime app.service writes a temporary override under /run/systemd/system that disappears after reboot. That is useful when you are not sure the machine will come back.
The classic root causes
/etc/fstabreferences a missing disk or bad filesystem; usenofailfor nonessential mounts.- The service starts before address assignment because network dependencies are wrong.
- Ownership or hardening drift blocks a config, state directory, device, or syscall after upgrade.
- Logs explicitly show an ordering cycle.
- The unit is fine and the application configuration is not.
- Memory or IO exhaustion causes timeouts that look like service bugs.
Fix the graph, not the symptom
Bad fixes keep reappearing: sleeps in wrappers, disabled rate limits, Restart=always as a substitute for startup correctness, broad ordering after every target, and chmod 777. Good fixes are legible in the unit: a correct dependency, the right owner, an adjusted timeout, or a narrow sandbox exception.
Field notes
- Capture evidence before restarting: status, journal slices, and
systemctl showoutput. systemctl cat unitshows the merged unit and all drop-ins; do not guess which file won.- If a unit is masked, start fails immediately until
systemctl unmaskremoves the mask. - Write down the broken assumption after every boot incident. Otherwise it returns with the next package upgrade.
Was this lesson helpful?