Debian – How to determine exactly why Systemd enters emergency mode

debiansystemdsystemd-journald

My desktop computer running Debian Jessie started dropping into an emergency mode shell on every boot up. The screen says to use journalctl -xb to find the reason, and to use systemctl default to continue booting. When I execute systemctl default, the system continues to boot, and after a couple weeks of using the system there is nothing apparently wrong.

Looking through journalctl -xb, nothing stands out as being the reason for dropping to an emergency shell. Is there an easy way to determine exactly the reason it decided to go into emergency mode? Are there other flags or bootup options that will make it obvious where the issue is?

Best Answer

The failure should have shown a red [ FAIL ] on the console (instead of [ OK ]), with the unit's description next to it. Typically the first failures are most important. Use shift+pageup on the console to scroll up and view the past few screenfuls of output. This might not work if there's too much output.

This works even if you don't normally see [ OK ] messages, e.g. due to quiet on the kernel command line as used by Debian. On the first failure, systemd switches to verbose mode.

Otherwise, you can use systemctl. Without any options, it shows a massive list of known units with failures highlighted in red. To show just the failed ones, use systemctl --state=failed or systemctl --failed.


If you search through the unit files, there are only a very few ways for the boot to fall back to emergency.target. It's usually when a .mount unit for a local filesystem fails, causing local-fs.target to fail. Or when your initramfs fails to mount the root filesystem, if your initramfs uses systemd.

local-fs.target has OnFailure=emergency.target. And it gets failed because units for local filesystems are automatically added to the Requires list of local-fs.target (unless they have DefaultDependencies=no).

$ systemctl show --property Requires local-fs.target
Requires=-.mount home.mount boot.mount boot-efi.mount
Related Question