Troubleshooting

You are in emergency mode: how to fix a Linux server that stops at boot

Fix 'You are in emergency mode' on Linux: read journalctl -xb, fix the fstab line or run fsck, get in when root is locked, then run systemctl default.

Published ~8 min read
On this page

Short answer: “You are in emergency mode” means systemd could not finish an early boot step, almost always mounting a file system from /etc/fstab or checking one with fsck, and stopped at a root shell instead. Log in with the root password, read the error with journalctl -xb, fix or comment out the bad fstab line (or repair the file system), then run systemctl default.

emergency shell · any systemd distribution
journalctl -xb -p err        # errors of this boot, with explanations
systemctl --failed           # which units failed (often a .mount or systemd-fsck@)
findmnt --verify             # check /etc/fstab for missing devices and typos
mount -o remount,rw /        # only if / is read-only and you need to edit
nano /etc/fstab              # fix the line, or put # in front of it (vi works too)
systemctl daemon-reload      # make systemd read the new fstab
systemctl default            # continue booting

The message on the console is printed by systemd-sulogin-shell. On our Debian 12 host (systemd 252) its text reads, word for word: You are in emergency mode. After logging in, type "journalctl -xb" to view system logs, "systemctl reboot" to reboot, "systemctl default" or "exit" to boot into default mode. Below it, sulogin asks Give root password for maintenance (or press Control-D to continue):. If instead you see Cannot open access to console, the root account is locked., jump to the root account is locked.

Why systemd drops into emergency mode

systemd.special(7) describes emergency.target as the most minimal way to get a shell: it pulls in no other services or mounts, and usually only PID 1 and your shell are running. Nothing else starts, so there is no network and no SSH. Two paths lead there during a normal boot, both visible in the unit files of systemd 252:

  • A required mount fails. local-fs.target carries OnFailure=emergency.target. systemd-fstab-generator(8) turns every fstab line into a mount unit, and per systemd.mount(5) each local line without nofail is required by local-fs.target. One missing disk is enough.
  • fsck finds errors it cannot fix. systemd-fsck(8) says the root check activates emergency.target on “Filesystem errors left uncorrected”, and a failed check of any other fstab file system without nofail or noauto makes local-fs.target fail, with the same result.

The usual reasons behind a failed mount:

CauseWhat the journal showsFix
Wrong UUID after a disk swap, a reformat or a restoreTimed out waiting for device /dev/disk/by-uuid/...Put the UUID from blkid in fstab
Disk removed or detached, entry still in fstabSame timeout, after 90 secondsDelete or comment out the line, or add nofail
Typo in the file system type or an optionFailed to mount /data.Correct it; findmnt --verify points at it
Network block device (iSCSI and similar) without _netdevMount fails before the network is upAdd _netdev (and nofail)
File system errorssystemd-fsck@...serviceUnmounted e2fsck -f or xfs_repair

NFS and CIFS shares behave differently. systemd recognises them by their type as network mounts and hangs them under remote-fs.target, which on systemd 252 has no OnFailure= line. An unreachable NFS server makes the boot slow and the mount fails, but it does not by itself put the server into emergency mode.

Emergency mode versus rescue mode

The two look alike, ask for the same root password and print the same kind of banner. The difference, per systemd.special(7), is how much of the system is running:

rescue.targetemergency.target
File systems from fstabMountedNot pulled in (root may be read-only)
Basic system (sysinit.target)StartedNot pulled in
Network, SSH, other servicesNoNo
Reached automaticallyNo, only on requestYes, when a mount or fsck fails
Kernel parametersystemd.unit=rescue.targetsystemd.unit=emergency.target
Short alias (systemd(1))rescue, single, 1emergency, -b

systemd.special(7) also notes that in emergency mode the root file system may be mounted read-only or read-write, depending on how the system got there. Hence the mount -o remount,rw / step before you edit anything.

Find out what failed

journalctl -xb shows the journal of the current boot; -x adds the explanation texts from systemd’s message catalog where one exists. On a long log, filter to errors with -p err and jump to the end with -e. The journalctl guide covers the other filters.

emergency shell
systemctl --failed                    # e.g. data.mount, systemd-fsck@dev-disk-by...
journalctl -b -p err                  # errors only
journalctl -xb -u data.mount          # one unit, with explanations
systemctl list-units --type=mount     # what is and is not mounted

A missing disk typically looks like this on the console. The lines below are illustrative, built from systemd 252’s own message formats with a made-up UUID:

console · illustrative
[ TIME ] Timed out waiting for device /dev/disk/by-uuid/3f6c1d2e-9a8b-4c7d-8e1f-2a3b4c5d6e7f.
[DEPEND] Dependency failed for /data.
[DEPEND] Dependency failed for Local File Systems.

The wait before that timeout is DefaultDeviceTimeoutSec=, 90 seconds by default per systemd-system.conf(5); during it the console counts up “A start job is running for /dev/disk/by-uuid/...”. Kernel messages about the disk itself (I/O errors, a missing controller) are in dmesg, see the dmesg command.

Fix the fstab line

First compare what fstab expects with what the machine has. blkid and lsblk -f list the real UUIDs; then let findmnt --verify (util-linux 2.29 and later) check the file. We ran it on our Debian 12 host (util-linux 2.38.1) against a test copy with --tab-file, with one made-up UUID and one typo:

findmnt --verify --tab-file fstab.test · output
0 parse errors, 2 errors, 1 warning
/srv
   [E] unreachable on boot required source: UUID=3f6c1d2e-9a8b-4c7d-8e1f-2a3b4c5d6e7f
/opt
   [W] extt4 seems unsupported by the current kernel
   [E] extt4 does not match with on-disk ext4

It exits with status 1 when it finds an error. In the same test a line with nofail and a missing disk was still reported with [E], so read the result next to the options: a missing disk with nofail will not stop the boot.

Then edit /etc/fstab and choose one of three fixes:

/etc/fstab · made-up UUIDs
# 1. wrong UUID: replace it with the one blkid prints for that partition
UUID=9b2e4f60-1c3d-4a5b-8e7f-0a1b2c3d4e5f  /data  ext4  defaults  0  2

# 2. disk gone for good: comment the line out
# UUID=3f6c1d2e-9a8b-4c7d-8e1f-2a3b4c5d6e7f  /backup  ext4  defaults  0  2

# 3. disk that may be absent: boot on without it, wait 10 s instead of 90 s
UUID=7a8b9c0d-1e2f-4a3b-9c4d-5e6f7a8b9c0d  /backup  ext4  defaults,nofail,x-systemd.device-timeout=10s  0  2

systemd.mount(5) explains both options: with nofail the mount is only wanted, not required, by local-fs.target, so boot continues whether or not it mounts, and x-systemd.device-timeout= sets how long systemd waits for the device. Keep nofail off the root file system and off anything your services cannot run without. The full fstab field reference is in how to mount a disk in Linux.

emergency shell
systemctl daemon-reload    # regenerate the mount units from fstab
mount -a                   # mount everything in fstab now: errors show up here
findmnt --verify           # should end with no errors for the remaining lines
systemctl default          # or: exit

The strings in Debian 12’s systemd-sulogin-shell show that leaving the shell with exit or Control-D reloads the system manager’s configuration and then starts default.target. If the cause is still there, you land in emergency mode again, which is why people see the prompt come back in a loop.

When fsck is the cause

If systemctl --failed lists a systemd-fsck@...service, the file system needs a manual check. Run it only on an unmounted file system: the failed mount is not active, but other fstab mounts may be, so make sure with findmnt /dev/sdb1, and if umount says the target is busy, see device or resource busy.

emergency shell · use your device name
lsblk -f                     # find the partition and its type
e2fsck -f /dev/sdb1          # ext2/3/4: forced check, asks before each fix
xfs_repair /dev/sdb1         # XFS: refuses to run on a mounted file system

fstab(5) says the sixth field (fs_passno) tells fsck the order: 1 for root, 2 for the others, 0 to skip; systemd-fstab-generator(8) treats it as a simple yes or no. When the damaged one is the root file system, you cannot check it from this shell because it is mounted. Boot with fsck.mode=force fsck.repair=yes (systemd-fsck(8)) or from a live ISO; the steps are in read-only file system.

“Cannot open access to console, the root account is locked”

sulogin needs root’s password, and many servers do not have one. Ubuntu disables the root account by default, and Debian’s installer disables it when you leave the root password empty. sulogin then prints the message above and Press Enter to continue., which only restarts the boot and leads back to the same message. rescue.target does not help: its service runs the same systemd-sulogin-shell and asks for the same password. Three ways in, all from the GRUB menu or the boot medium:

  • init=/bin/bash. At the GRUB menu press e, append it to the line that starts with linux and boot with Ctrl+X. You get a root shell without systemd and without a password. Run mount -o remount,rw /, fix /etc/fstab, then sync and exec /sbin/init to continue booting. The details are in not in the sudoers file.
  • SYSTEMD_SULOGIN_FORCE=1. systemd’s environment variable documentation says it skips the password when root’s is not available, for example when the account is locked. systemd(1) documents systemd.setenv= to pass variables to the processes PID 1 starts, so appending systemd.setenv=SYSTEMD_SULOGIN_FORCE=1 to the kernel line should give you the emergency shell without a password.
  • A live or rescue ISO. Boot it through your provider’s console, mount the root partition, and edit etc/fstab below that mount point.

On a VPS or dedicated server

Emergency mode starts no network and no sshd, so from outside the server simply looks down: SSH times out and the IP may not even answer ping. You reach the shell only through your provider’s VNC or serial console (on a dedicated server, the remote management console). Copy and paste often fails there, so keep the fix short: comment out the line, systemctl default, and do the careful work over SSH once the server is up again. After a planned disk change, run findmnt --verify before you reboot, and once it is back, check with findmnt or df -h that every disk is mounted where your data expects it.

Frequently asked

What does 'You are in emergency mode' mean?

systemd could not complete an early boot step and started emergency.target, a root shell with no services, no network and no SSH. The usual cause is an /etc/fstab entry whose disk is missing or misspelt, or a file system check that found errors it could not fix. Log in with the root password and run journalctl -xb to see what failed.

How do I get out of emergency mode?

Fix the cause first, usually by correcting or commenting out the bad line in /etc/fstab, then run systemctl daemon-reload and systemctl default, or type exit. Leaving the shell without a fix starts the default target again and brings you straight back to emergency mode. If / is read-only, run mount -o remount,rw / before editing.

What if the root account is locked in emergency mode?

sulogin then prints 'Cannot open access to console, the root account is locked' and cannot give you a shell, and rescue mode asks for the same password. Edit the kernel line in GRUB and add init=/bin/bash, remount / read-write and fix /etc/fstab, or boot a live ISO from your provider's console. Ubuntu, and Debian installed without a root password, have root locked by default.

What is the difference between rescue mode and emergency mode?

Rescue mode (rescue.target) starts the basic system and mounts all file systems from /etc/fstab, but no normal services. Emergency mode (emergency.target) pulls in no other mounts or services, and the root file system may still be read-only. systemd enters emergency mode by itself when a required mount or fsck fails; rescue mode only when you ask for it with systemd.unit=rescue.target.

Related articles

All troubleshooting