๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Linux Emergency Mode After Editing fstab: Recovery Steps

Linux Emergency Mode After Editing fstab: Recovery Steps

You added a data disk or an NFS share to /etc/fstab, ran reboot, and the console now says "Welcome to emergency mode" right after "Dependency failed for Local File Systems". SSH is dead, and all you have is a hypervisor or IPMI console. That is the classic linux emergency mode fstab incident.

The fix is usually one line. The time goes into two things: getting a writable root shell when the root account is locked, and finding out which of several plausible lines is the culprit. This walkthrough covers the whole incident in order, so you read the evidence before you change anything.

Why one bad fstab line stops the whole boot

How systemd turns fstab entries into mount units

At early boot, systemd-fstab-generator reads /etc/fstab and writes a .mount unit for each line. A line for /data becomes data.mount, with a dependency on the device it names. Local mounts without nofail are pulled in with Requires= by local-fs.target. If one of them fails, the target fails and systemd switches to emergency.target.

Old sysvinit systems printed an fsck or mount error and carried on booting, which is why this feels like a regression to people who learned on them.

What the emergency mode screen actually tells you

The usual console text looks like this:

[ TIME ] Timed out waiting for device /dev/disk/by-uuid/3f1c9a2e-7b40-4d1e-9c55-0a8e2f6b1d77.
[DEPEND] Dependency failed for /data.
[DEPEND] Dependency failed for Local File Systems.
You are in emergency mode. After logging in, type "journalctl -xb" to view
system logs, "systemctl reboot" to reboot, or "exit" to continue bootup.

The "Timed out" line is why it looks like a hang. A missing device is waited on for 90 seconds by default, from DefaultTimeoutStartSec or a per-line x-systemd.device-timeout=, before systemd gives up.

emergency.target is the minimal state: root mounted read-only, almost no services, and a single sulogin prompt. rescue.target starts a basic system and attempts local mounts, so it is not a reliable way around a bad entry.

Getting a root shell when the password is locked

Normal case: root password set

If root has a password, emergency mode asks for it. Type it, press Enter, and you have a shell. Skip ahead to reading the evidence.

Locked root on Ubuntu and cloud images

Ubuntu and most cloud images ship with root locked, so sulogin refuses you:

Cannot open access to console, the root account is locked.
See sulogin(8) man page for more details.
Press Enter to continue.

Pressing Enter just tries to continue booting, which fails again. Setting systemd.unit=emergency.target does not help here, because it ends in the same sulogin. On Debian-family systems, systemd.setenv=SYSTEMD_SULOGIN_FORCE=1 on the kernel line makes sulogin open a shell anyway. That is a trade-off, since anyone with console access gets root without a password, so treat it as a one-off. The cleaner route is init=/bin/bash, shown below. Many cloud providers also offer a serial console or a rescue mode that attaches your disk to another instance.

Using the GRUB editor when emergency mode will not give you a prompt

Reboot, and at the GRUB menu press e. If the menu is hidden, hold Shift (BIOS) or tap Esc (UEFI). Find the line starting with linux and append to it:

linux /boot/vmlinuz-... root=UUID=... ro quiet splash init=/bin/bash

Press Ctrl+X to boot. You get a root shell with no password and the root filesystem read-only.

On RHEL, Rocky and Alma, append rd.break instead. You land in the initramfs with the real root at /sysroot, so run mount -o remount,rw /sysroot and chroot /sysroot. After editing files there, run touch /.autorelabel so SELinux relabels on the next boot.

Reading the evidence before you edit anything

journalctl and systemctl --failed

Do not comment out lines yet. Ask systemd what failed:

journalctl -xb -p err --no-pager | less
systemctl --failed
systemctl list-units --type=mount --state=failed

A failed data mount usually reads like one of these:

systemd[1]: Timed out waiting for device dev-disk-by\x2duuid-3f1c9a2e\x2d7b40\x2d4d1e\x2d9c55\x2d0a8e2f6b1d77.device.
systemd[1]: Dependency failed for data.mount - /data.
mount[412]: mount: /data: wrong fs type, bad option, bad superblock on /dev/sdb1,
            missing codepage or helper program, or other error.

"Timed out waiting for device" means the UUID or device name does not exist. "Wrong fs type" means the device is there but the type or options are wrong. The Systemd & Journalctl cheat sheet has more filters if the log is noisy.

findmnt --verify and blkid against fstab

Next, check the file itself. findmnt --verify (util-linux 2.29 and later) parses /etc/fstab and checks targets, sources and filesystem types. It does not mount anything or touch the disk.

findmnt --verify --verbose
/data
   [E] unknown filesystem type 'ext5'
   [W] target does not exist
   [W] unreachable on boot required source: UUID=3f1c9a2e-7b40-4d1e-9c55-0a8e2f6b1d77
0 parse errors, 1 error, 2 warnings

Exact wording varies by version. Now compare against what the disks really carry:

lsblk -f
blkid /dev/sdb1

If the UUID in blkid differs from the one in fstab, you have your answer. Save the broken file first. Root is still read-only, so copy to tmpfs: cp /etc/fstab /run/fstab.bad. Then cat /etc/fstab and look hardest at the line you last touched.

The five usual causes and the exact fix for each

Match what you saw in the journal to one row, then apply that fix.

Journal symptomCauseFix
Timed out waiting for deviceUUID typo or disk reformattedCopy the current UUID from blkid
Timed out waiting for deviceDisk absent or optionalnofail,x-systemd.device-timeout=5s
wrong fs type, bad optionWrong type or invalid optionMatch lsblk -f, strip bad options
mount point does not existDirectory missingmkdir -p /data
NFS/CIFS timeout or hangMounted before the network_netdev,nofail,x-systemd.automount

Wrong UUID, wrong device name, or a disk that is gone

Run blkid and paste the current UUID into fstab. Prefer UUID= over /dev/sdb1, because device names change with probe order and added disks.

# before
/dev/sdb1                                  /data  ext4  defaults  0  2
# after
UUID=9d2e41b8-5c0a-4f7e-8b13-6a1f0c2d9e54  /data  ext4  defaults,nofail,x-systemd.device-timeout=5s  0  0

The six fields are device, mount point, type, options, dump flag and fsck pass. Pass 1 is for /, 2 is for other disks checked after it, and 0 skips the check. On a non-root data disk, 0 means a failing fsck cannot block boot, at the price of no automatic check.

Warning: nofail hides the failure from the boot. If /data is missing, a database or backup job will happily write into the empty directory on the root filesystem. Add RequiresMountsFor=/data to those units so they refuse to start without the mount; the systemd service management book covers such dependencies.

Typos in the filesystem type, options or mount point

Compare the type field with the TYPE that blkid reports. Writing ext4 for an XFS volume gives "wrong fs type". Options fail the same way: a trailing comma as in defaults,discard,, or Windows-oriented options such as uid=, umask= or windows_names on ext4. dmesg | tail names the offender, for example "unrecognized mount option".

A missing mount point shows up as "mount point does not exist". systemd normally creates the directory itself, but that can fail when the parent is read-only or on another filesystem that is not mounted yet. Run mkdir -p /data and move on.

NFS and CIFS mounts that need the network

systemd orders nfs and cifs mounts after the network on its own, but a down server still holds up boot. Make the mount lazy and non-fatal:

nas01:/export/backup  /mnt/backup  nfs  _netdev,nofail,x-systemd.automount,x-systemd.idle-timeout=60  0  0

x-systemd.automount mounts on first access, so boot never waits for the server. If something must have the share at startup, use x-systemd.requires=network-online.target instead. Both options are documented in systemd.mount.

Remount root read-write, apply the fix, and test without rebooting

Make the filesystem writable

Emergency mode mounts / read-only, so saving fstab fails until you remount:

mount -o remount,rw /
vi /etc/fstab

Use vi, since nano is often missing in this minimal environment. If you only need the machine up, put # in front of the bad line and boot. Debug in a full system afterwards.

Validate with mount -a and a reload

systemd builds mount units from fstab at boot and on reload. Skip the reload and it keeps acting on the old file.

systemctl daemon-reload
findmnt --verify
mount -a
findmnt /data
df -h /data

A failing entry prints the cause:

mount: /data: special device UUID=3f1c9a2e-... does not exist.

That line says the UUID is wrong. "Wrong fs type, bad option" points at the type or options field instead. For local mounts, if mount -a finishes silently, the next boot will pass too. Then run systemctl default to continue booting, or reboot.

When emergency mode itself will not start: chroot from a live ISO

Sometimes there is no emergency shell to fix things from. The kernel panics with VFS: Unable to mount root fs on unknown-block(0,0), sulogin fails, or the mistake is in the root entry itself. Boot a live ISO or your provider's rescue image, mount the real system under /mnt and work inside a chroot.

Mount the real root filesystem and bind the pseudo filesystems

Identify the partitions with lsblk -f first. This is the whole flow for a plain partition layout on UEFI:

lsblk -f
mount /dev/sda2 /mnt
mount /dev/sda1 /mnt/boot/efi        # UEFI only; mount a separate /boot first if you have one
for d in dev proc sys run; do
  mount --rbind /$d /mnt/$d
  mount --make-rslave /mnt/$d
done
chroot /mnt /bin/bash
vi /etc/fstab
update-initramfs -u -k all           # Debian/Ubuntu, if the root UUID changed
dracut -f --regenerate-all           # RHEL family, same condition
exit
umount -R /mnt
reboot

--make-rslave stops the final unmount from propagating back into the live system. Use --regenerate-all with dracut, because plain dracut -f builds for the live ISO's running kernel, not the installed one.

A wrong root UUID in fstab is a different problem from a wrong root= on the kernel command line. The kernel takes root= from GRUB, not fstab. Check grep root= /boot/grub/grub.cfg and /etc/default/grub, then regenerate with update-grub or grub2-mkconfig -o /boot/grub2/grub.cfg.

LVM and LUKS: activate before you mount

If lsblk -f shows LVM2_member or crypto_LUKS, nothing under /dev/mapper exists until you open it. Run these before the mount lines above:

cryptsetup open /dev/sda3 cryptroot     # LUKS, asks for the passphrase
vgchange -ay                            # LVM
mount /dev/mapper/vg0-root /mnt         # use /dev/mapper/cryptroot if LVM is not on top

Your volume group and mapper names will differ, so read them from lsblk and vgs. If you changed anything that affects early boot, such as a LUKS UUID in /etc/crypttab, rebuild the initramfs as shown above.

Never edit fstab without a safety net again

A pre-reboot validation routine

Make this sequence a habit, and never reboot on an unchecked fstab:

cp -a /etc/fstab /etc/fstab.$(date +%F)
vi /etc/fstab
systemctl daemon-reload
findmnt --verify
mount -a
umount /data && mount -a && findmnt /data

The last line proves the entry mounts from fstab alone, not from a manual mount you ran earlier. findmnt documents what --verify does and does not check. It cannot tell you whether a network share will be reachable at boot.

On a remote server, confirm that console access actually works before you touch fstab, and take a hypervisor snapshot if you can. Ansible's mount module with state=mounted writes the line and mounts it, but add a findmnt --verify task, because a green run does not prove the next boot will pass.

Defensive mount options for optional and network storage

For shares and secondary disks, use nofail,x-systemd.automount,x-systemd.device-timeout=5s so boot never depends on them. When a service needs a mount in a specific order, a hand-written .mount unit with explicit After= and Requires= is clearer than stacking fstab options.

Reading boot logs from the previous failed boot after you recover

Once the machine is back up, keep the evidence. The failed boot is still in the journal, but only if the journal survived the reboot.

Check that the journal is persistent

List the boots journald knows about:

journalctl --list-boots
IDX BOOT ID                          FIRST ENTRY                 LAST ENTRY
 -1 5e0b7c1a9d2f4c68a1b3f07e2d94c6aa Tue 2025-03-11 09:12:44 UTC Tue 2025-03-11 09:19:02 UTC
  0 c47a90e3b8d14f5e9a6d21f0be73815c Tue 2025-03-11 09:21:10 UTC Tue 2025-03-11 09:34:57 UTC

If only index 0 appears, the journal lives in /run/log/journal and vanished at reboot. Persistence is on when /var/log/journal exists with the default Storage=auto, or when you set Storage=persistent in /etc/journald.conf. Debian and Ubuntu usually have the directory, while some other distributions ship without it. Make it persistent now, so the next failure leaves a trail.

Pull the failed boot apart

With a previous boot available, filter it down to errors and the mount unit:

journalctl -b -1 -p err --no-pager
journalctl -b -1 -u data.mount -u local-fs.target --no-pager
Mar 11 09:14:15 srv01 systemd[1]: dev-disk-by\x2duuid-3f1c9a2e\x2d....device: Job ... timed out.
Mar 11 09:14:15 srv01 systemd[1]: Timed out waiting for device /dev/disk/by-uuid/3f1c9a2e-....
Mar 11 09:14:15 srv01 systemd[1]: Dependency failed for data.mount - /data.

Compare the first systemd[1] entries of that boot with the timeout line. The gap is the 90 seconds you stared at the console.

Confirm the delay with systemd-analyze

systemd-analyze reports on the current boot only. It will show the timeout if you booted again with the bad entry still present, for example after adding nofail without a shorter device timeout. In that case boot completes, but late:

systemd-analyze blame | head -3
1min 30.012s dev-disk-by\x2duuid-3f1c9a2e\x2d7b40\x2d4d1e\x2d9c55\x2d0a8e2f6b1d77.device
      4.210s cloud-init.service
      2.874s apt-daily.service

systemd-analyze critical-chain
graphical.target @1min 33.1s
โ””โ”€multi-user.target @1min 33.1s
  โ””โ”€local-fs.target @1min 31.5s
    โ””โ”€data.mount @1min 31.5s
      โ””โ”€dev-disk-by\x2duuid-3f1c9a2e\x2d....device @1.4s +1min 30.0s

The numbers are illustrative and the columns differ slightly between versions. What matters is the +1min 30.0s on the device unit, sitting directly under local-fs.target. nofail stops the failure from being fatal, but boot still waits for the timeout. Adding x-systemd.device-timeout=5s cuts that to five seconds, and x-systemd.automount removes the wait entirely.

For deeper slow-boot work, see systemd boot time analysis and the boot time optimization cheat sheet.

Emergency-mode fstab recovery checklist

  1. Get a root shell: password, init=/bin/bash, rd.break on RHEL, or a live ISO.
  2. Save the broken file with cp /etc/fstab /run/fstab.bad before changing anything.
  3. Read journalctl -xb -p err and systemctl --failed, then run findmnt --verify and blkid.
  4. Match the symptom to a cause: UUID, type or options, mount point, network, or missing disk.
  5. Run mount -o remount,rw /, fix the line, then systemctl daemon-reload and mount -a.
  6. Add nofail only to storage the system can live without, and guard dependent services with RequiresMountsFor=.
  7. On SELinux systems, run touch /.autorelabel if you used rd.break.
  8. Reboot, then confirm with findmnt --verify and systemctl --failed.

If boot failures keep landing on you, the Broken Linux eBook goes through more recovery scenarios in this style.

Frequently Asked Questions

How do I get out of emergency mode in Linux without the root password?

Reboot, press e at the GRUB menu and append init=/bin/bash to the linux line. On RHEL-family systems use rd.break instead. Remount root read-write, fix fstab, and reboot. If you cannot edit GRUB, boot a live ISO or your provider's rescue image and chroot into the system.

What does nofail do in fstab and when should I use it?

With nofail, a missing or failing mount no longer fails local-fs.target, so boot continues normally. Use it for secondary disks, removable drives and network shares. Do not use it for /, /usr or /var, and guard dependent services with RequiresMountsFor= so they cannot write into an empty directory.

Why does systemd wait 90 seconds for a device that is not there?

systemd gives a missing device a default start timeout of 90 seconds before it fails the mount. That is the "hang" on the console before emergency mode appears. Shorten it per entry with x-systemd.device-timeout=5s, and add nofail if the disk is optional.

Do I need to run daemon-reload after editing /etc/fstab?

Yes. systemd generates mount units from fstab at boot and on reload, so without systemctl daemon-reload it keeps using the old data. You may see a warning that the mount unit changed on disk. Plain mount -a reads the file directly, but reload first so both agree.

Is it safe to use /dev/sdb1 instead of UUID in fstab?

No. Names like /dev/sdb1 depend on probe order and can change when you add a disk, swap a controller or reboot. Then the wrong partition mounts, or none does. Use UUID=, LABEL= or PARTUUID=, and read the values from blkid or lsblk -f. See fstab(5).

Share this article:
Dorian Thorne
About the Author

Dorian Thorne

Cloud Infrastructure, Cloud Architecture, Infrastructure Automation, Technical Documentation

Dorian Thorne is a cloud infrastructure specialist and technical author focused on the design, deployment, and operation of scalable cloud-based systems.

He has extensive experience working with cloud platforms and modern infrastructure practices, including virtualized environments, cloud networking, identity and acces...

Cloud Computing Cloud Networking Identity and Access Management Infrastructure as Code System Reliability

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.