Break the boot with a bad fstab entry and recover from the console

short · 40 min · Objective 4.2

Task

Give lin-b an fstab entry for a file system that does not exist, reboot, and recover from the emergency shell it drops into: read the journal to find the cause, fix the file, and boot normally. Then read the failed boot's log afterwards with the previous-boot option, the way you would investigate a crash you did not witness.

Steps

  1. Add a line to /etc/fstab mounting UUID= followed by an invented UUID at /srv/missing, with default options. Save the line to lab/boot/bad-line.txt, then reboot.
  2. When the emergency shell appears, log in as root and save journalctl -xb -p err to a file on the root file system for later.
  3. Fix it: remount root read-write if needed, comment out or remove the bad line, and reboot.
  4. After a normal boot, save journalctl -b -1 -p err (the failed boot) to lab/boot/previous-boot.txt -- if it says no persistent journal was found, the failed boot's log is gone, so copy in the file you saved in step 2 instead -- and systemctl --failed to lab/boot/failed-units.txt.
  5. Record in lab/boot/prevent.txt the mount option that would have let the server boot despite the missing disk, and when you would use it.

Verify

These checks run in a POSIX shell: Terminal on macOS or Linux, and on Windows Git Bash (it comes with Git for Windows) or WSL. A stock Windows PowerShell or Command Prompt has no awk or grep, so there the first line fails.

grep -c 'UUID=' lab/boot/bad-line.txt
grep -Eic 'srv-missing|dependency failed|timed out|not found' lab/boot/previous-boot.txt
grep -Eic '0 loaded units|0 units' lab/boot/failed-units.txt
grep -Eic 'nofail' lab/boot/prevent.txt

The previous boot's errors name the missing mount, and after the fix no units have failed. The option is nofail, which lets boot continue if the device is absent -- right for a data disk the server can run without, wrong for one its applications cannot, where stopping is safer than starting without the data.

Notes

The Windows equivalents are the Recovery Environment's command prompt, bcdedit and bootrec for boot configuration, and the System log's Kernel-Power 41 and BugCheck events for an unexpected restart.

This is an independent study companion for CompTIA Server+ SK0-005 and is not produced by or endorsed by CompTIA.