Linux Storage & Mounting Master Guide: /etc/fstab, UUIDs, LVM, NFS, SMB/CIFS

Last Verified On: Kernel 6.8 / 6.12 LTS / Ubuntu 24.04 LTS & Debian 12/13 Moderate (Service Restart) Exit Code: 32

Direct Answer / TL;DR

Most mount failures on Ubuntu 24.04, Debian 12, and RHEL 9 come from wrong UUIDs, missing network options, or stale fstab-generated units. Validate with findmnt --verify, get UUIDs via lsblk -f, add nofail,_netdev plus x-systemd.automount to NFS/CIFS entries, then run systemctl daemon-reload.

findmnt --verify --tab-file /etc/fstab

Core Architecture & Mechanics

The mount stack is a three-layer pipeline. At the bottom, the kernel VFS binds a filesystem superblock into the calling process’s mount namespace via the modern syscall chain fsopen() → fsconfig() → move_mount() (kernel 5.2+, replacing the legacy single mount(2)). In the middle, libmount (util-linux) parses the six whitespace-delimited fields of /etc/fstab for mount(8), umount(8), and findmnt(8). At the top, systemd-fstab-generator converts each fstab line into transient units under /run/systemd/generator/: the mountpoint /mnt/nas/projects becomes mnt-nas-projects.mount. Generator output is cached, so an fstab edit is inert until systemctl daemon-reload or mount -a runs — editing fstab and rebooting without validation is how frozen boots are manufactured.

Identifier semantics matter more than most admins assume. UUID= and LABEL= are read from the filesystem superblock by libblkid probing and mirrored by udev into /dev/disk/by-uuid/ and /dev/disk/by-label/. PARTUUID= and PARTLABEL= come from the GPT/MBR partition table, not the filesystem. Consequences: reformatting a partition (mkfs.xfs) rewrites the fs UUID but keeps PARTUUID=; repartitioning does the reverse; a dd clone duplicates the fs UUID so two disks race during enumeration — fix with tune2fs -U random (ext4) or xfs_admin -U generate (XFS, unmounted). Never persist raw /dev/sdX names: kernel block enumeration order is nondeterministic across reboots, hotplug, and driver probe changes.

LVM inserts a device-mapper layer between the block device and the filesystem. Devices initialized with pvcreate register as Physical Volumes; vgcreate aggregates them into a Volume Group of 4 MiB extents; lvcreate carves Logical Volumes exposed as /dev/mapper/<vg>-<lv>. LVM metadata lives in each PV header and is archived on every metadata change into /etc/lvm/archive/ — the rollback source for vgcfgrestore. Activation is event-driven via lvm2-monitor.service and systemd autoactivation, so a missing PV surfaces in pvs as [unknown] and the VG activates partially instead of failing the boot outright.

NFS (nfs.ko) and SMB/CIFS (cifs.ko) are network filesystems: their fstab device field is host:path or //host/share. NFSv3 requires rpcbind, mountd, and per-port firewall holes; NFSv4 is single-port TCP 2049 with the export tree rooted at the server’s fsid=0 pseudo-filesystem, identities translated by nfsidmapd upcalls. CIFS negotiates an SMB dialect; auto-negotiation falls back to insecure SMB1 on legacy servers and fails with errno 95 (EOPNOTSUPP) or 112 (EHOSTDOWN), so always pin vers=3.1.1 or vers=3.0. CIFS has no POSIX ownership model — identity is emulated per mount via uid=/gid=/file_mode=/dir_mode= — and authentication belongs in a credentials= file with mode 0600, never inline in the world-readable fstab.

Complete Reference Table / Diagnostic Matrix

fstab grammar: <device> <mountpoint> <fstype> <options> <dump> <pass>, whitespace-separated; options are comma-separated with no embedded spaces. Mountpoints containing spaces are written as 40. Field 5 (dump) is legacy — always 0. Field 6 (pass): 1 for / only, 2 for other native filesystems checked by fsck, 0 for swap, XFS, and all network filesystems.

Item / Code / Flag Behavior Common Cause / Use Case
UUID= / LABEL= Resolved from the filesystem superblock via libblkid; udev symlinks under /dev/disk/by-uuid mkfs regenerates the UUID and leaves fstab stale — always cross-check with lsblk -f after any re-format
PARTUUID= / PARTLABEL= Read from the GPT/MBR partition table Survives reformatting but not repartitioning; preferred for ESP/boot where FAT is reformatted
/dev/mapper/<vg>-<lv> LVM logical volume node; needs lvm2 activation at boot Missing node at boot = VG inactive; check vgs, add the lvm2 initramfs hook when / is on LVM
host:path with nfs4 RPC tree mount; NFSv4 uses TCP 2049 only rpcbind/mountd/firewall/vers mismatch → mount.nfs: Connection timed out
//host/share with cifs SMB tree connect via the mount.cifs helper Missing cifs-utils → unknown filesystem type 'cifs'; dialect fallback → error(112)
nofail systemd proceeds with boot despite a failed mount Mandatory on every entry except /; omission drops the machine to emergency mode on a dead NAS
_netdev Orders the mount after network-online.target Missing on NFS/CIFS → early-boot mount attempt fails inside the link-up window
x-systemd.automount Automount unit mounts on first path access; unmounts via idle-timeout Standard for shares and laptops; also makes NFS hard mounts safe (idle unmount releases D-state)
x-systemd.idle-timeout=120 Unmounts after N idle seconds Reduces NFSv3 stale-file-handle exposure; frees the share for clean server maintenance
x-systemd.device-timeout=10s Caps the wait for the device to appear/reach Default 90 s per absent disk stalls boot — set small on removable and network devices
hard / soft, timeo=150, retrans=3 NFS RPC retry policy; hard parks I/O in uninterruptible D state if the server dies soft returns EIO and corrupts writes; use hard only with automount + idle-timeout
vers=4.2 (NFS) / vers=3.1.1 (CIFS) Pins the protocol floor on both sides Negotiation mismatch → error 95 EOPNOTSUPP or an incorrect mount option was specified
sec=ntlmssp / krb5i (CIFS) Selects the auth flavor; krb5i requires an id-mapped cifs upcall Mismatch → Permission denied (13) or status c000006d in dmesg
uid= gid= file_mode= dir_mode= Emulates POSIX ownership/modes per CIFS mount Wrong uid → files appear owned by nobody; set to the consuming service UID/GID
credentials=/etc/cifs.cred Reads user=/password=/domain= from a file chmod 0600 root:root required; never inline pass= in fstab options
root_squash (server export) Maps client UID 0 to nobody:NOGROUP on the server no_root_squash is a privilege-escalation hole; keep root_squash default
dump=0, pass=1|2|0 Legacy dump flag + fsck(8) ordering pass 1 only for /; 0 for XFS (offline xfs_repair), swap, and network FS
mkfs.xfs / mkfs.ext4 / pvcreate Destructive: rewrites superblock metadata, mints a new UUID Dry-run first: wipefs -n <dev> plus a blkid cross-check against fstab entries
lvreduce -L Destructive; XFS cannot shrink, so lvreduce on XFS LVs is impossible ext4: shrink the filesystem first, then lvreduce --test dry-run before the real call
vgreduce –removemissing Destructive: drops the dead PV and every LV with extents on it Dry-run: vgreduce --test --removemissing; only after vgcfgbackup
vgcfgbackup / vgcfgrestore Saves/replays VG metadata from /etc/lvm/archive The rollback path after any LVM edit; run vgcfgbackup after every change
findmnt –verify –tab-file /etc/fstab Static validator: resolves every source, flags option conflicts; exit 0 only when clean Run before every reboot after an fstab edit — the single highest-value habit

Multi-Distro Implementation Differences

fstab option syntax is identical everywhere; what differs is package naming, service units, SELinux/firewall, and who consumes fstab at boot (systemd-fstab-generator vs OpenRC netmount).

Ubuntu / Debian

# Client+server package set
sudo apt-get install -y lvm2 nfs-common nfs-kernel-server cifs-utils
sudo systemctl enable --now nfs-kernel-server.service
sudo systemctl enable nfs-client.target remote-fs.target

# Back up fstab and record identifiers before any edit
sudo cp /etc/fstab /etc/fstab.bak.$(date +%F-%H%M)
lsblk -f

# Append a safe CIFS line (one physical line in fstab)
printf '//srv1/projects /mnt/projects cifs credentials=/etc/cifs.cred,vers=3.1.1,uid=1001,gid=1001,file_mode=0664,dir_mode=0775,nofail,_netdev,x-systemd.automount,x-systemd.idle-timeout=120 0 0n' | sudo tee -a /etc/fstab
sudo chmod 0600 /etc/cifs.cred

# Validate, regenerate transient units, mount now — no reboot needed
sudo findmnt --verify --tab-file /etc/fstab
sudo systemctl daemon-reload
sudo mount -a -v

RHEL / AlmaLinux / Rocky

sudo dnf install -y lvm2 nfs-utils cifs-utils policycoreutils-python-utils
sudo systemctl enable --now nfs-server.service

# NFSv3 compatibility: rpcbind + mountd; NFSv4-only needs only the nfs service
sudo firewall-cmd --permanent --add-service=nfs --add-service=rpc-bind --add-service=mountd
sudo firewall-cmd --reload

# SELinux: label the export root so client identity mapping works
sudo semanage fcontext -a -e /home /export/projects
sudo restorecon -Rv /export/projects
sudo exportfs -rav

Arch Linux

sudo pacman -S --needed lvm2 nfs-utils cifs-utils

# Root-on-LVM only: the 'lvm2' HOOK must precede 'filesystems' in /etc/mkinitcpio.conf
grep '^HOOKS=' /etc/mkinitcpio.conf
sudo mkinitcpio -P

sudo systemctl enable nfs-client.target remote-fs.target
sudo findmnt --verify --tab-file /etc/fstab && sudo systemctl daemon-reload

Alpine / Containers

apk add lvm2 nfs-utils cifs-utils
rc-update add rpcbind default && rc-service rpcbind start
rc-update add netmount default    # OpenRC consumes fstab network entries at boot

echo 'srv1:/export/projects /mnt/projects nfs4 nofail,hard,timeo=150,retrans=3 0 0' >> /etc/fstab
mount -a

# Containers: mount() needs CAP_SYS_ADMIN
# docker run --cap-add SYS_ADMIN ... with host nfs/cifs modules loaded

Common Failure Modes & Troubleshooting Recipes

1. Boot drops to emergency mode after an fstab edit. Journal shows Dependency failed for /mnt/projects.mount; getuid() drops you at sulogin. Rescue live, validate, reboot:

mount -o remount,rw /
grep -n 'projects' /etc/fstab          # locate the offending line, fix or comment it
findmnt --verify --tab-file /etc/fstab
umount -f -l /mnt/projects 2>/dev/null
systemctl daemon-reload && reboot

2. wrong fs type, bad option, bad superblock on /dev/sdb1 — stale or duplicated UUID. Typical after dd clones or an unrecorded re-format:

lsblk -f | grep -A1 sdb
sudo blkid /dev/sdb1
sudo grep -n 'UUID=' /etc/fstab
# Fix: replace the stale UUID in fstab; deduplicate clone UUIDs (device unmounted):
sudo xfs_admin -U generate /dev/sdb1    # XFS
sudo tune2fs -U random /dev/sdb1        # ext4

3. Boot hang on an NFS/CIFS share (default 90 s device wait, then emergency mode). Confirm the unit, then rebuild the entry with automount so a dead server cannot freeze the boot:

journalctl -b --no-pager | grep -E 'mnt-projects.mount|timed out|Timeout'
systemctl list-units --type=automount --all
# fstab line (single line) with bounded waits:
# srv1:/export/projects /mnt/projects nfs4 nofail,_netdev,hard,timeo=150,retrans=3,x-systemd.device-timeout=10s,x-systemd.automount,x-systemd.idle-timeout=300 0 0

4. NFS stale file handle after server re-IP or re-export. The kernel holds a stale export handle; drop the mount lazily and re-mount with a pinned version:

umount -l -f /mnt/projects
rpcinfo -p srv1 | grep -E 'nfs|mountd'
showmount -e srv1                       # lists v3 exports only; check v4 with exportfs -v on the server
mount -v -t nfs4 -o vers=4.2,hard srv1:/ /mnt/projects

Note: NFSv4 mounts the server’s fsid=0 pseudo-root; subdirectories appear below the mountpoint without separate exports.

5. CIFS error(112) Host is down / Permission denied (13). Root causes: SMB1-only server, wrong dialect, or bad credential file permissions:

dmesg --level=err | grep -i cifs | tail
stat -c '%a %U' /etc/cifs.cred          # expect: 600 root
mount -t cifs //srv1/projects /mnt/projects -o vers=3.1.1,sec=ntlmssp,credentials=/etc/cifs.cred,uid=1001,gid=1001,file_mode=0664,dir_mode=0775,nofail

6. LVM VG inactive or PV missing after array loss. Diagnose, reactivate, then dry-run before any destructive cleanup:

pvs -a 2>&1 | grep -i unknown
vgs -o vg_name,vg_missing_pv_count
sudo vgchange -ay vg_data               # reactivate
sudo pvscan --cache                     # refresh kernel device cache
# PV permanently gone — safety + DRY-RUN first:
sudo vgcfgbackup vg_data
sudo vgreduce --test --removemissing vg_data
sudo vgreduce --removemissing --force vg_data   # destructive: LVs on the dead PV are lost
# Rollback path:
sudo vgcfgrestore -f /etc/lvm/archive/vg_data_00012-1234567890.vg vg_data

7. XFS corruption — never run fsck on XFS. Unmount first; xfs_repair -n is the read-only check:

umount /dev/mapper/vg_data-lv_app
xfs_repair -n /dev/mapper/vg_data-lv_app    # read-only dry-run
xfs_repair /dev/mapper/vg_data-lv_app       # destructive metadata rewrite

8. Pre-reboot full validation. Never trust an unverified fstab:

sudo findmnt --verify --tab-file /etc/fstab && echo FSTAB-OK
sudo mount -a -v -f -n                  # fake dry-run: full parse path, no kernel mount, no mtab write
sudo systemctl daemon-reload

Production Hardening & Safety Checklist

Safety Check:

  • Back up before editing: cp -a /etc/fstab /etc/fstab.bak.$(date +%F-%H%M); rollback is cp /etc/fstab.bak.<stamp> /etc/fstab && systemctl daemon-reload.
  • Static validation is mandatory: findmnt --verify --tab-file /etc/fstab must exit 0 before any reboot; follow with the fake mount mount -a -v -f -n.
  • Never persist /dev/sdX — prefer UUID= (native FS), /dev/mapper/* (LVM), PARTUUID= (boot/ESP).
  • Only / may omit nofail; every NFS/CIFS entry additionally requires _netdev and ideally x-systemd.automount + x-systemd.device-timeout.
  • Destructive LVM ops require vgcfgbackup first and the --test dry-run flag (lvreduce --test, vgreduce --test --removemissing). XFS cannot shrink — never plan lvreduce on an XFS LV.
  • Before any mkfs/pvcreate: run wipefs -n <dev>, confirm the target with blkid, and grep fstab for its current UUID — destroying a referenced disk is unrecoverable.
  • CIFS credentials: chmod 0600, root:root; never embed pass= inline in fstab options.
  • XFS repair is offline-only; always run xfs_repair -n (read-only) before the real pass.
  • First remote reboot after a mount change: keep an out-of-band console (IPMI/iLO/VNC) open and a rescue USB staged.

Frequently Asked Edge Cases

How do I regenerate an fs UUID without reformatting the filesystem?

Unmount first, then run `tune2fs -U random /dev/sdX1` for ext4 or `xfs_admin -U generate /dev/sdX1` for XFS. This resolves duplicate UUIDs left by dd clones so fstab entries stop racing at enumeration time.

Why does mounting NFS or CIFS inside a Docker container fail with permission denied?

The mount syscall requires CAP_SYS_ADMIN, which containers lack. Run with `--cap-add SYS_ADMIN`, confirm the host has loaded the `nfs`/`cifs` kernel modules, and on Alpine install `nfs-utils` plus `cifs-utils` userspace inside the image.

Is x-systemd.automount safe for the root filesystem?

No. Automounting `/` deadlocks because systemd resolves the path while the mount unit is starting. Keep `/` on ordinary fstab options with pass=1; apply automount only to data shares.

References & Upstream Docs

  1. Linux man-pages: man 5 fstab, man 8 mount, man 8 findmnt, man 8 blkid, man 8 mount.nfs, man 8 mount.cifs
  2. Upstream Kernel / Systemd Documentation: systemd-fstab-generator(8), systemd.mount(5), systemd.automount(5) at freedesktop.org
  3. Upstream Kernel / Systemd Documentation: docs.kernel.org — Documentation/filesystems/nfs/ and cifs/
  4. LVM2: man 8 vgcfgbackup, man 8 vgcfgrestore, man 8 lvreduce, man 8 vgreduce

Related Concepts