Here: what systemd does when the boot cannot go on, and how emergency mode differs from rescue mode.
The fstab lines without nofail are mounted by local-fs.target, and the rest of the boot depends on it. When a line does not mount, the target is not reached, and systemd starts emergency mode, the emergency.target. The machine's console shows the message You are in emergency mode and a root shell, and systemctl is-system-running prints maintenance: the machine is waiting for a person.
Before the shell, systemd asks for the root password. On the training machine the root login is locked, but the emergency shell is set up to open without a password. On a server the root password is set in advance: without it you cannot get into emergency mode.
The other mode of this kind is rescue.target, rescue mode. You put the machine into it yourself when the filesystems are fine but you need to stop before the services:
| emergency | rescue | |
|---|---|---|
| filesystems | the root and whatever managed to mount | everything from fstab |
| how you get there | systemd itself, when a filesystem does not mount | with systemctl rescue or from the boot loader menu |
| what for | fixing fstab or a filesystem | fixing a service or a setting |
A service fails at boot because of its config, and the config lives on the /var/lib/app partition from fstab. It has to be fixed before the services start. Which mode will you put the machine into?
-
In a normal boot the service starts with the broken config before the fix, and the task is to fix it before the services start.
-
Emergency mounts the root and whatever managed to attach: the /var/lib/app partition may be missing, leaving nothing to edit. Rescue is the one that mounts all filesystems from fstab.
Rescue mounts every filesystem from fstab and stops before the services, so the config on /var/lib/app is reachable while the service has not started. Emergency does not fit, since not everything is mounted there.
Key points
-
An fstab line without
nofailthat does not mount stops the boot: systemd starts emergency.target. -
In emergency mode the console holds a root shell, and
systemctl is-system-runningprintsmaintenance. - Rescue mounts every filesystem from fstab, emergency only the root and whatever managed to attach.