fstab, Start to Finish: Local Disks, Swap, NFS, CIFS, Bind Mounts, and the Ones You Leave Out

unixshadow — /etc/fstab
# findmnt --verify

fstab, Start to Finish: Local Disks, Swap, NFS, CIFS, Bind Mounts, and the Ones You Leave Out

The map of the box. Six fields per line, and every one of them has bitten someone at 2am.
/etc/fstab is the list of filesystems the system mounts — local disks, swap, network shares, and the odd ones. It is read by programs and never written by them: you maintain it by hand, and the order of the lines matters, because fsck, mount and umount walk it in order. On a systemd box it is also the input to the generator that builds mount units at boot and on every daemon-reload — so an fstab edit is a unit change, not just a text change. # = run as root. Every command in this post runs as root, on the box whose fstab you are editing.
# at 2am, start here — the box won’t boot, or a mount is missing
# findmnt --verify --verbose   # is fstab even parseable, and is every entry usable
# findmnt                      # what is actually mounted right now
# lsblk -f                     # devices, UUIDs, and filesystem types as the kernel sees them
# systemctl list-units --failed   # which mount units failed
# journalctl -xb -p err        # why they failed
# mount -a                     # try the missing ones by hand, after fixing the file
# systemctl daemon-reload      # after editing fstab, so systemd rebuilds the mount units
A failed mount at boot is almost always one of three things: a typo in the file, a device that is not there yet, or a network share whose server is not reachable. findmnt --verify catches the first before you reboot; the rest is ordering, and that is what the options below are for.
# the anatomy — six fields, and what each one buys you

The six fields, and what each one buys you

# device                mount point   type   options            dump  pass
UUID=3e6be9de-8139-11d1-9106-a43f08d823a6   /       xfs    defaults           0     1
UUID=9f2c41aa-77b0-4d9e-b8c1-2e55f0a1c7d3   /home   xfs    defaults,noatime   0     2
UUID=5b1d8e04-3a6f-4c2a-9d0e-7c44a9b2e6f1   /data   ext4   defaults           0     2
Field one is the device: a path, a LABEL=, a UUID=, or for GPT disks a PARTUUID=/PARTLABEL=. Use the UUID or label — device names are an accident of detection order and change when a disk is added or removed. Field two is the mount point (none for swap). Field three is the type, or swap for swap space. Field four is the comma-separated options. Field five is the dump flag: 0, always, unless you still run dump — nobody does. Field six is the fsck order: root is 1, other filesystems 2, 0 means do not check. Filesystems on different drives are checked in parallel; on the same drive, sequentially.
Two things worth knowing about defaults. First, it is not a fixed list in mount — the kernel default is usually rw, suid, dev, exec, auto, nouser, async, and the filesystem may add its own. Second, options are order-sensitive: the last one wins when they conflict, so defaults,noatime is read-write with atime updates off, and noatime,defaults would undo it.
# local disks — the boring correct way

A local disk, the boring correct way

# lsblk -f                     # UUIDs and types, as the kernel sees them
# blkid /dev/sdb1              # one device, close up
Find the UUID first, then write the line. The mount point must exist before boot reads the file — a missing directory fails the mount, and on a required filesystem that stops the boot.
# mkdir -p /data
# mount -a                     # mount everything in fstab that is not mounted yet — the test, without a reboot
# findmnt /data                # what is actually mounted there, and with which options
That is the test: it mounts everything in fstab that is not already mounted, so a bad line fails here, in front of you, instead of at 3am on a reboot. findmnt then shows the effective options — what the kernel actually applied, including the defaults the file never spelled out.

XFS and the fsck field

# xfs_admin -l /dev/sdb1       # read the label off an XFS filesystem
# xfs_admin -L data01 /dev/sdb1   # set a label, so the fstab line can say LABEL=data01
XFS entries still carry passno 2 by convention, but the check does nothing at boot: fsck.xfs exits without touching the filesystem unless a forced check is requested. XFS replays its journal on mount, and a real repair is xfs_repair, run by hand, with the filesystem unmounted. The 2 is harmless — keep it, so the file reads the same for every filesystem.

SSDs: don’t put discard in fstab

# systemctl status fstrim.timer   # the weekly trim — shipped enabled on RHEL
Continuous discard trims on every delete. The weekly fstrim.timer batches it instead, which is what RHEL ships enabled. Leave discard out of the fstab line and let the timer do it.
# swap — in fstab, not just in the installer

Swap in fstab

# /dev/vg0/swap   none   swap   sw            0 0   # the line, as it sits in the file
# /dev/sdb2      none   swap   sw,pri=10      0 0   # a second device, higher priority
Swap entries use none as the mount point and swap as the type. The option is sw; pri= sets the priority from 0 to 32767, higher first, and the kernel spreads pages across devices of equal priority. With no priority set, the kernel assigns negative numbers, so a device with an explicit pri= always wins over one without.
# swapon --show                # what is actually active, and at which priority
A swap file works the same way — the first field is the path to the file — but the file must already exist and be initialised with mkswap before boot reads the line.
# tmpfs — RAM that pretends to be a disk

tmpfs: RAM that pretends to be a disk

# tmpfs   /tmp   tmpfs   defaults,size=2G,mode=1777   0 0
tmpfs lives in RAM (and swap, under memory pressure). The size is an upper limit, not a reservation: size=2G caps it at 2 GB, size=0 removes the limit, and with no size given the default is half of physical RAM. mode= sets the permissions of the root directory — 1777 for a shared scratch space like /tmp, tighter for anything private. nr_inodes= caps the inode count; its default is half the number of RAM pages.
The first field can be anything — tmpfs, none, mem — it just shows up in df output. And do not add /dev/shm to fstab: systemd mounts it, and a second entry fights the generator.
# network filesystems — the ones that hang the boot

An NFS share that doesn’t hang the boot

# dnf install nfs-utils        # the client side: mount.nfs and the helpers
# mkdir -p /mnt/nfs
# mount -t nfs nfs.example.com:/export/data /mnt/nfs   # try it by hand first
Mount it by hand before it goes in the file. If the manual mount works, the fstab line is just that command written down.
# nfs.example.com:/export/data   /mnt/nfs   nfs   defaults,_netdev,nofail,x-systemd.automount,timeo=600,retrans=5   0 0
Each option earns its place. _netdev tells systemd the share needs the network, so it waits for it. nofail makes the mount wanted, not required: if the server is down, boot carries on instead of waiting and failing. x-systemd.automount mounts the share on first access rather than at boot — the share is there when you need it and absent when you don’t, and a dead server costs you nothing at boot. timeo=600 is 60 seconds per attempt (the unit is deciseconds), retrans=5 is five retries.

Hard, soft, and the version

# nfs.example.com:/export/data   /mnt/nfs   nfs   defaults,_netdev,nofail,vers=4.2   0 0
With no version given, the client tries 4.2 first and negotiates down to whatever the server speaks. Pin vers= only when the server is old. And leave the mount hard — it is the default, and it means a process waits for the server to come back rather than getting an error. soft gives up after retrans attempts and returns EIO, which looks like the file vanished; on a read-write mount that can silently corrupt data. Use soft only on read-only mounts where responsiveness matters more than the data.

A Windows share without the password in fstab

# dnf install cifs-utils       # the client side: mount.cifs and the helpers
# install -m 600 /dev/null /root/smb.cred   # the credentials file, root-readable only
The credentials file holds three lines: username=, password=, domain=. Mode 600, root-owned — fstab is world-readable, so a password in the options field is a password on display. The credentials= option exists precisely so the password never appears there.
# //fileserver.example.com/projects   /mnt/projects   cifs   credentials=/root/smb.cred,vers=3.1.1,sec=ntlmssp,uid=1000,gid=1000,file_mode=0640,dir_mode=0750,_netdev,nofail,x-systemd.automount   0 0
Pin the dialect with vers=3.1.1. With no vers= given, the client negotiates the highest version both sides support — SMB 2.1 or above on any modern kernel, usually ending at 3.1.1 — but the negotiated default varies by kernel, and old defaults were SMB1, which is deprecated and only safe on a private network. sec=ntlmssp is the kernel’s default authentication; say it anyway, so the line reads the same on every box. The server does not provide Unix ownership, so uid= and gid= decide who owns the files locally, and file_mode=/dir_mode= set the permission bits shown — without them, everything looks root-owned and every file looks executable.
# bind and overlay — the same files, a second address; two trees, one view

Bind mounts: the same files, a second address

# mkdir -p /srv/shared
# mount --bind /data/shared /srv/shared   # try it by hand first
A bind mount attaches an existing directory at a second path. It creates nothing in the kernel — the same filesystem, visible twice. The fstab form uses none as the type:
# /data/shared   /srv/shared   none   bind   0 0
rbind does the same thing recursively, carrying any mounts nested underneath along. And a bind mount is only as early as its source: if the source is itself a mount, the bind must come after it, so add x-systemd.requires=/data to the options — it builds a Requires and After dependency on the source mount unit.

A read-only bind mount takes two steps

# mount --bind /data/shared /srv/shared
# mount -o remount,bind,ro /data/shared /srv/shared   # the remount makes it read-only
A single call with bind,ro does the same thing in one step — userspace remounts it behind the scenes — but the two-step form is the one that has worked on every release, and it is what the fstab line with bind,ro amounts to.

Overlayfs: two trees, one view

# mkdir -p /opt/app-ro /var/app-rw/upper /var/app-rw/work /merged
# mount -t overlay overlay -o lowerdir=/opt/app-ro,upperdir=/var/app-rw/upper,workdir=/var/app-rw/work /merged
Overlayfs stacks a writable upper tree over a read-only lower one. Reads come from whichever layer has the file; writes go to the upper. The lower can be anything, even another overlay; the upper must be writable and support extended attributes, so NFS is not suitable as an upper layer. The workdir must be an empty directory on the same filesystem as the upper — it is the kernel’s scratch space, not yours.
# overlay   /merged   overlay   noauto,x-systemd.automount,lowerdir=/opt/app-ro,upperdir=/var/app-rw/upper,workdir=/var/app-rw/work   0 0
The noauto plus x-systemd.automount pair matters here: an overlay whose layers are not ready at boot will hang the mount, so it mounts on first access instead. Multiple lower layers stack with colons: lowerdir=/lower1:/lower2.
# images and the ones you leave out — loop mounts, and the filesystems systemd already owns

Loop mounts: files that pretend to be disks

# mount /tmp/disk.img /mnt -t vfat -o loop=/dev/loop3   # one image, one loop device, named
# mount -o loop /tmp/rescue.iso /mnt/iso               # or let mount pick a free loop device
An image file mounts through a loop device. In fstab the same line carries the loop option, and the type is whatever is inside the image — iso9660 for an ISO, squashfs for a read-only image, vfat or ext4 for a disk image. The file must exist before boot reads the line, so loop mounts of files on a network share do not belong in fstab.
# /opt/images/rescue.iso   /mnt/iso   iso9660   loop,ro,nofail   0 0
Read-only and nofail: an image is not worth a hung boot.

The filesystems you do NOT put in fstab

# findmnt --real   # real filesystems only — the pseudo ones are systemd's
proc, sysfs, devpts, cgroup, securityfs — systemd mounts these early, before fstab is even read. Listing them is redundant at best and fights the generator at worst. The man page says it plainly: special filesystems like udev and sysfs are typically not listed in fstab. The same goes for /dev/shm, which is a tmpfs systemd mounts for you. fstab is for the filesystems you chose, not the ones the init system owns.
# after editing — verify, reload, test; and getting out of a bad boot

After editing: verify, reload, test

# findmnt --verify --verbose   # parseable? every source reachable? every mount point present?
# systemctl daemon-reload      # rebuild the mount units from the edited file
# mount -a                     # mount what is missing, without a reboot
# mount /mnt/nfs               # or just one entry, by mount point
# findmnt --verify             # and confirm it is all clean
That is the order: verify the file, reload the units, test the mounts, verify again. The verify flag checks parsability and usability — a missing mount point, an unknown type, an unreachable source — and --verbose says why. A single entry can be tested on its own, by mount point or by device — the rest of the file is left alone.

When a bad line hangs the boot

# systemctl list-units --failed   # which mount units failed
# journalctl -xb -p err        # why they failed
Without nofail, a missing device or dead server stops the boot at that mount: systemd waits for the device up to the device timeout, then drops to emergency mode. From there, the root filesystem is mounted read-only — remount it writable, fix the line, and reboot:
# mount -o remount,rw /        # emergency mode: root is read-only until you remount it
# vi /etc/fstab                # fix the line, or comment it out
# systemctl reboot
If the file is so broken that emergency mode is not enough, the kernel command line takes fstab=no: the generator ignores fstab entirely and the box boots without any of its mounts. Fix the file, remove the parameter, reboot. And the cheapest insurance is the one already in this post: nofail on anything that is not on a local disk, and x-systemd.automount on anything across the network — a share that cannot be reached should cost you a missing mount, never a missing boot.
# quick reference — the whole post as a table
I need to… Command
Check fstab before rebooting findmnt --verify --verbose
See what is actually mounted findmnt
Find a disk’s UUID lsblk -f or blkid /dev/sdb1
Test new fstab lines without rebooting systemctl daemon-reload, then mount -a
Mount one fstab entry only mount /mnt/nfs
Label an XFS filesystem xfs_admin -L data01 /dev/sdb1
Add swap, higher priority first /dev/sdb2 none swap sw,pri=10 0 0
See active swap and priorities swapon --show
Cap a tmpfs at 2 GB tmpfs /tmp tmpfs defaults,size=2G,mode=1777 0 0
Mount an NFS share at boot, safely nfs.example.com:/export/data /mnt/nfs nfs defaults,_netdev,nofail,x-systemd.automount 0 0
Pin the NFS version vers=4.2 in the options field
Mount a Windows share without a password in fstab //fileserver.example.com/projects /mnt/projects cifs credentials=/root/smb.cred,vers=3.1.1,_netdev,nofail 0 0
Make a CIFS share writable by one user uid=1000,gid=1000,file_mode=0640,dir_mode=0750
Show the same files at a second path /data/shared /srv/shared none bind 0 0
Stack a writable layer over a read-only one overlay /merged overlay lowerdir=/opt/app-ro,upperdir=/var/app-rw/upper,workdir=/var/app-rw/work 0 0
Mount an ISO image /opt/images/rescue.iso /mnt/iso iso9660 loop,ro,nofail 0 0
Find why a mount failed at boot systemctl list-units --failed, then journalctl -xb -p err
Boot with fstab ignored entirely fstab=no on the kernel command line
Read: UUIDs, not device names. Test: findmnt –verify, daemon-reload, mount -a — before the reboot, not after. Network: _netdev, nofail, automount — a dead server costs a missing mount, never a missing boot. Secrets: credentials file, mode 600, never in the options field. Leave out: proc, sysfs, /dev/shm — systemd already owns those. Recover: emergency mode, remount rw, fix the line.

Sources: fstab(5), mount(8), tmpfs(5), swapon(8), systemd.mount(5), systemd-fstab-generator(8), findmnt(8) — AlmaLinux 10, util-linux 2.40.2, systemd 257; fsck.xfs as shipped on AlmaLinux 10. NFS and CIFS: Red Hat Enterprise Linux 10, Managing file systems — Mounting NFS shares and Mounting an SMB share. Overlayfs: mount(8), “Mount options for overlay”.

unixshadow · fstab, the map of the boxPublished 17 Nov 2026

Scroll to Top