Troubleshooting Failed fstab Mounts: How to Debug Unmounted Partitions After Reboot


2 views

html

When working with Linux systems, it's frustrating to discover after reboot that some partitions declared in /etc/fstab failed to mount while others worked perfectly. The real challenge comes when you can't access boot console messages to see the actual error.

Start by checking these critical locations for mount-related errors:

# Check systemd logs for mount units
journalctl -u systemd-fsck
journalctl -u local-fs.target

# View kernel messages from last boot
dmesg | grep -i mount
dmesg | grep -i error

# Check authentication logs (for NFS/Samba)
grep -i mount /var/log/auth.log

From experience, these are the most frequent culprits:

  • Missing dependencies: Network mounts attempting before network is up
  • UUID changes: Common after disk replacements or repartitioning
  • Filesystem errors: Requiring manual fsck intervention
  • Permission issues: Especially with encrypted or special devices

Let's examine a real troubleshooting session for an NFS mount failure:

# First check if mount unit exists
systemctl list-units | grep -i nfs

# Then examine its status
systemctl status mnt-data.mount

# Sample output showing root cause:
● mnt-data.mount - /mnt/data
   Loaded: loaded (/etc/fstab; generated)
   Active: failed (Result: exit-code) since Thu 2023-05-18 09:45:22 EDT
     Where: /mnt/data
     What: 192.168.1.100:/export/data
  Process: 1234 ExecMount=/bin/mount nfs (code=exited, status=32)

For stubborn cases, these commands provide deeper insight:

# Test fstab entries without actually mounting
findmnt --verify --verbose

# Check filesystem availability at boot time
systemd-analyze critical-chain local-fs.target

# Generate dependency graph
systemd-analyze dot | dot -Tsvg > bootgraph.svg

To avoid future issues:

# Use this fstab entry format for network mounts
# (Adds _netdev and x-systemd.automount options)
server:/share  /mnt/share  nfs  _netdev,x-systemd.automount,x-systemd.requires=network-online.target  0  0

# For local filesystems, consider adding:
nofail,x-systemd.device-timeout=5s

Create a script to validate fstab entries pre-reboot:

#!/bin/bash
while read -r line; do
  [[ "$line" =~ ^# ]] || [[ -z "$line" ]] && continue
  
  device=$(echo $line | awk '{print $1}')
  mountpoint=$(echo $line | awk '{print $2}')
  
  echo "Testing mount of $device to $mountpoint"
  mkdir -p "$mountpoint"
  if mount "$device" "$mountpoint"; then
    echo "SUCCESS: $device mounted successfully"
    umount "$mountpoint"
  else
    echo "ERROR: Failed to mount $device (exit code $?)"
  fi
done < /etc/fstab

When Linux systems boot, /etc/fstab should mount all specified partitions automatically. But sometimes, certain entries silently fail without obvious errors. Here's how to investigate when you can't access boot console messages.

Check these log files immediately after a failed mount attempt:

# Systemd systems (most modern distros)
journalctl -b -p err..alert
journalctl -u systemd-fsck

# Traditional syslog systems
grep -i mount /var/log/syslog
grep -i fsck /var/log/kern.log

Despite identical formatting, these subtle differences often cause failures:

# Working example (ext4 with UUID)
UUID=1234-5678 /mnt/data ext4 defaults 0 2

# Failing examples:
UUID=1234-5678 /mnt/data ext3 defaults 0 2  # Filesystem type mismatch
UUID=1234-5678 /mnt/backup ext4 defaults,nofail 0 2  # Missing nofail for network storage
LABEL=OldDisk /mnt/legacy ext4 defaults 0 2  # Label changed after disk replacement

Add this to your fstab line for debugging:

UUID=1234-5678 /mnt/data ext4 defaults,x-systemd.debug-shell=1 0 2

Then check debug output with:

systemctl status debug-shell.service

Create a pre-boot check script (/etc/initramfs-tools/scripts/init-premount/fstab-check):

#!/bin/sh
PREREQ=""
prereqs() { echo "$PREREQ"; }
case $1 in
prereqs)
    prereqs
    exit 0
    ;;
esac

for entry in $(awk '$1 ~ /^UUID=|^LABEL=|^\/dev\// {print $2}' /etc/fstab); do
    if [ ! -d "$entry" ]; then
        echo "fstab mount point missing: $entry" > /dev/kmsg
        mkdir -p "$entry"
    fi
done

For critical mounts, consider explicit mount units (/etc/systemd/system/mnt-data.mount):

[Unit]
Description=Mount Data Partition

[Mount]
What=/dev/disk/by-uuid/1234-5678
Where=/mnt/data
Type=ext4
Options=defaults

[Install]
WantedBy=multi-user.target

Enable with:

systemctl enable mnt-data.mount