Skip to main content
RunBook Academy

LinuxXV · /etc/fstab and Mount ManagementBoot recovery

Recovering from a broken fstab without a live USB

Intermediate⏱ ~10 minbashsystemctlmountnanovi

What you'll learn

  • Recover a host that fails to boot because of an fstab entry
  • Use systemd emergency mode to edit fstab
  • Use the initramfs shell for deep recovery
  • Mount the root filesystem read-write from emergency mode
  • Distinguish an emergency-mode read-only root from one the kernel demoted with errors=remount-ro, before remounting

Prerequisites

Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09

Not yet marked complete on this device.

A bad fstab entry - wrong UUID, missing filesystem, typo in the mount point - prevents the host from booting. The recovery path is the same: get to an emergency shell, mount the root filesystem read-write, fix fstab, reboot.

Diagnosing the failure

Read-only / Safeverify fstab
$ findmnt --verify --verbose
0 parse errors, 1 error, 0 warnings
/data
[ ] target exists
[ ] userspace options: nofail
[E] unreachable on boot required source: UUID=00000000-0000-0000-0000-000000000000
Configuration changeregenerate mount units
$ sudo systemctl daemon-reload
Configuration changemount the rest
$ sudo mount -a

Recovering via systemd emergency mode

Data-loss riskreboot to firmware
$ systemctl reboot --firmware-setup
Data-loss riskGRUB emergency
$ systemd.unit=emergency.target

Once in emergency mode, read the kernel log before you remount anything:

Read-only / Safewhy is / read-only?
$ journalctl -k -b --no-pager | grep -iE 'EXT4-fs error|XFS.*(Corruption|Internal error)|Buffer I/O error|blk_update_request|medium error|Remounting filesystem read-only'

If that grep is clean, the read-only root is just emergency.target and the remount is safe:

Configuration changeremount rw
$ mount -o remount,rw /
Configuration changefix fstab
$ vi /etc/fstab
Data-loss riskreboot
$ reboot
  1. Document the fstab error and the fix in the post-incident review
  2. Add a nofail option to non-critical mounts in fstab to prevent future boot hangs
  3. Set up a runbook with the emergency shell procedure
  4. Test the recovery procedure on a clone host before relying on it in production

Recovery via the initramfs shell

If the root filesystem itself cannot be mounted, you must stop the boot before the pivot to the real root. That is the initramfs shell, and it is reached with a distribution-specific kernel parameter.

The real initramfs shell - root will not mount

Data-loss riskdracut initramfs shell
$ rd.break
Data-loss riskinitramfs-tools shell
$ break=mount

From that shell the real root is not yet mounted, so there is no /etc/fstab to fix yet. The job is to find the root device and bring it online:

  1. blkid - list every block device with its UUID, LABEL and filesystem type. Compare against the root= parameter the bootloader passed.
  2. lvm vgscan && lvm vgchange -ay - activate volume groups if the root is on LVM. A root that "cannot be mounted" is very often just an inactive VG.
  3. mdadm --assemble --scan - assemble software RAID arrays if the root is on md.
  4. cryptsetup luksOpen /dev/sdaN root - unlock the root if it is encrypted.
  5. mount -o ro /dev/<root-device> /sysroot - mount the root read-only first, so a damaged filesystem is not written to before you have looked at it.
  6. Inspect /sysroot/etc/fstab. If it is the problem, remount read-write with mount -o remount,rw /sysroot and edit it.
  7. exit - the initramfs continues the boot from where it stopped.

init=/bin/bash - root mounts, userspace is broken

Use this when emergency mode itself will not start - a corrupted journal, a broken systemd unit, a mangled /etc/passwd. The root filesystem must still be mountable.

The kernel starts bash as PID 1 with nothing else set up. No /proc, no /sys, no services, and the root mounted read-only. mount -o remount,rw / fails with a confusing error until /proc is mounted, because mount reads /proc/self/mountinfo. Mount the pseudo-filesystems first:

Configuration changeprepare the PID 1 shell
# mount -t proc proc /proc && mount -t sysfs sys /sys && mount -o remount,rw /
Data-loss riskhand back to systemd
# sync && mount -o remount,ro / && exec /sbin/init

Common fstab mistakes

MistakeSymptomFix
/dev/sda1 changed to /dev/sdb1 after hardware changeHost does not bootUse UUID instead
Mount point does not existmount fails at bootCreate the directory or fix the path
Filesystem type wrongmount failsUse auto to let the kernel detect, or set the correct type
Missing nofail on a network mountHost hangs at bootAdd nofail so boot continues, or fix the network
Typo in UUIDmount failsblkid to find the right UUID
Missing 0 2 at the endNothing breaks: fields 5 and 6 are optional and default to 0. But dump=0 fsck=0 means the filesystem is never checked at boot, so corruption accumulates unnoticedWrite all six columns. Use fsck pass 1 for / and 2 for other local filesystems; 0 for network and bind mounts

Knowledge check

Knowledge check · 4 questions

  1. Q1. What is the first step to recover a host with a broken fstab?

  2. Q2. The shell you get from init=/bin/bash comes from the real root filesystem, so the root must already have mounted.

  3. Q3. Which of the following are correct for fstab recovery? Select all that apply.

  4. Q4. A RHEL host fails to boot. The console shows the root logical volume was never activated, so the root cannot be mounted. You have console access. What do you do first?

Passing score: 75%. Answers are checked in this browser.