troubleshooting2025-06-28·9·15/348

Recovering from Boot Failure After Editing /etc/fstab

Step-by-step guide to recovering a Linux system that fails to boot after incorrect /etc/fstab modifications, including live USB recovery and fstab repair.

Recovering from Boot Failure After Editing /etc/fstab

Editing /etc/fstab is a rite of passage for Linux sysadmins. One wrong entry and your system will not boot. I once added an NFS mount with an incorrect path, and the system dropped to an emergency shell. This guide covers the recovery process step by step.

Environment

  • OS: Ubuntu 22.04 LTS
  • Cause: Incorrect NFS mount entry in /etc/fstab
  • Symptom: System drops to emergency shell during boot
# The incorrect fstab entry that caused the problem
nas-server:/exports/data  /mnt/data  nfs  defaults,_netdev  0  0
# Should have been:
192.168.1.100:/exports/data  /mnt/data  nfs  defaults,_netdev  0  0

The Problem

After rebooting, the system failed to start:

[ FAILED ] Failed to mount /mnt/data.
See 'systemctl status mnt-data.mount' for details.

You are in emergency mode. After logging in, type "journalctl -xb" to view
system log, "systemctl reboot" to reboot, "systemctl default" or "exit"
to boot into default mode.
root@server:~# 

Analysis

Step 1: Identify the Problematic Entry

# Check systemd mount units
root@server:~# systemctl status mnt-data.mount
● mnt-data.mount - /mnt/data
     Loaded: loaded (/etc/fstab; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2025-06-28 10:00:00 WET; 5min ago

root@server:~# journalctl -xb | grep -A5 "mnt-data"
Jun 28 10:00:00 server systemd[1]: mnt-data.mount: Mount process exited, code=exited, status=32/n/a
Jun 28 10:00:00 server kernel: NFS: ... mount server not responding
Jun 28 10:00:00 server systemd[1]: mnt-data.mount: Failed with result 'exit-code'.

Step 2: Check Current fstab

root@server:~# cat /etc/fstab
#                
UUID=xxxx-xxxx  /               ext4    errors=remount-ro 0       1
UUID=yyyy-yyyy  /boot           ext4    defaults          0       2
UUID=zzzz-zzzz  none            swap    sw                0       0
nas-server:/exports/data  /mnt/data  nfs  defaults,_netdev  0  0

The NFS entry has an incorrect server address.

Solution

Fix 1: Edit fstab in Emergency Mode

Emergency mode gives you root access. Edit fstab directly:

# Remount root filesystem read-write
root@server:~# mount -o remount,rw /

# Edit fstab
root@server:~# nano /etc/fstab

# Comment out or fix the problematic entry
# nas-server:/exports/data  /mnt/data  nfs  defaults,_netdev  0  0
192.168.1.100:/exports/data  /mnt/data  nfs  defaults,_netdev  0  0

# Exit and reboot
root@server:~# exit

Fix 2: Boot from Live USB

If emergency mode does not work:

# Boot from Ubuntu Live USB
# Open terminal and find your root partition
$ sudo fdisk -l
Device     Start       End   Sectors   Size Type
/dev/sda1   2048   1026047   1024000   500M EFI System
/dev/sda2 1026048 104857599 103831552  49.5G Linux filesystem

# Mount root partition
$ sudo mount /dev/sda2 /mnt

# If you have a separate /boot partition
$ sudo mount /dev/sda1 /mnt/boot

# Mount critical virtual filesystems
$ sudo mount --bind /dev /mnt/dev
$ sudo mount --bind /dev/pts /mnt/dev/pts
$ sudo mount --t proc proc /mnt/proc
$ sudo mount --t sysfs sysfs /mnt/sys

# Chroot into the system
$ sudo chroot /mnt

# Now edit fstab
# nano /etc/fstab
# Fix the problematic line
# Save and exit

# Exit chroot
$ exit

# Reboot
$ sudo reboot

Fix 3: Boot with init=/bin/bash

For severe cases where even emergency mode fails:

# At GRUB menu, press 'e' to edit
# Find the linux line and add init=/bin/bash

# Before:
linux /vmlinuz-5.15.0-xxx root=UUID=xxxx ro quiet splash

# After:
linux /vmlinuz-5.15.0-xxx root=UUID=xxxx ro quiet splash init=/bin/bash

# Boot with Ctrl+X or F10
# Remount root as read-write
# mount -o remount,rw /

# Edit fstab
# nano /etc/fstab

# Sync and reboot
# sync
# reboot -f

Fix 4: Use systemd.unit=emergency.target

# At GRUB, edit the linux line:
linux /vmlinuz-5.15.0-xxx root=UUID=xxxx ro systemd.unit=emergency.target

# In emergency shell:
mount -o remount,rw /
nano /etc/fstab

Fix 5: Backup and Restore fstab

# If you have a backup
root@server:~# cp /etc/fstab /etc/fstab.broken
root@server:~# cp /etc/fstab.backup /etc/fstab
root@server:~# mount -a
root@server:~# reboot

Prevention Strategies

Always Test fstab Changes

# Test fstab without rebooting
$ sudo mount -a
# If no errors, the entries are valid

# Validate UUIDs exist
$ sudo blkid
/dev/sda1: UUID="xxxx-xxxx" TYPE="ext4"

# Check NFS server reachability
$ showmount -e nas-server

Create fstab Backup Before Editing

#!/bin/bash
# /usr/local/bin/safe-fstab-edit.sh

BACKUP="/etc/fstab.backup.$(date +%Y%m%d)"
cp /etc/fstab "$BACKUP"
echo "Backup created: $BACKUP"
nano /etc/fstab
echo "Testing fstab..."
if mount -a 2>/dev/null; then
    echo "fstab is valid"
else
    echo "Error detected! Restoring backup..."
    cp "$BACKUP" /etc/fstab
    echo "Backup restored"
fi

Use nofail for Non-Critical Mounts

# Add nofail to prevent boot failure if mount is unavailable
nas-server:/exports/data  /mnt/data  nfs  defaults,_netdev,nofail  0  0

# The system will boot even if the NFS server is unreachable

Common fstab Mistakes

MistakeSymptomFix
Wrong UUIDBoot failureUse `blkid` to find correct UUID
Wrong mount pointSpecific mount failsVerify directory exists
Wrong fs typeMount failureCheck `blkid` for TYPE
Missing nofailBoot hangs on network mountAdd `nofail` option
Wrong NFS pathMount timeoutTest with `showmount -e`

Lessons Learned

  1. Always test fstab changes with mount -a before rebooting.
  2. Keep a backup of /etc/fstab before any modification.
  3. Use nofail for network mounts and non-critical filesystems.
  4. Learn the GRUB edit flow - pressing 'e' at boot to modify kernel parameters is a lifesaver.
  5. Document all mount changes in a runbook for team reference.

This blog does not accept any external sponsorships, affiliate marketing, or ad revenue.