fstab
Static filesystem table for mounting filesystems, swap, encrypted volumes, and network shares at boot.
Getting Started
What /etc/fstab Does
/etc/fstab defines filesystems and swap areas that should be mounted automatically.
Each entry is processed at boot and can also be applied manually later.
Edit fstab
sudoedit /etc/fstab
Back Up Before Changes
sudo cp /etc/fstab /etc/fstab.bak.$(date +%F-%H%M%S)
Validate Syntax
findmnt --verify --verbose
Apply New Mount Entries
sudo mount -a
Apply Swap Entries
sudo swapon -a
Entry Format
Generic Layout
[source] [mount_point] [filesystem] [options] [dump] [pass]
Field Meanings
| Field | Meaning |
|---|---|
source | Device, UUID, LABEL, mapper path, or network export |
mount_point | Directory where the filesystem appears |
filesystem | Filesystem type such as ext4, xfs, vfat, swap, nfs, nfs4, tmpfs |
options | Comma-separated mount options |
dump | Usually 0; legacy backup flag |
pass | Filesystem check order at boot |
Common pass Values
| Value | Meaning |
|---|---|
0 | Do not run fsck |
1 | Check first, usually root filesystem |
2 | Check after root |
Identify Filesystems Safely
UUIDs and labels are more stable than /dev/sdX names.
Show UUIDs
blkid
Show Filesystems and Mountpoints
lsblk -f
Show Current Mount Tree
findmnt
Common Local Filesystem Entries
ext4 Partition by UUID
Use this as the default pattern for most local data partitions.
UUID=[uuid] [mount_point] ext4 defaults 0 2
XFS Partition by UUID
Use 0 0 because XFS is not checked by fsck in the same way as ext filesystems.
UUID=[uuid] /srv/data xfs defaults 0 0
EFI System Partition
This is the common Linux EFI entry.
UUID=[uuid] /boot/efi vfat umask=0077 0 1
Read-Only Archive Mount
Useful for snapshots, archives, or forensic copies.
UUID=[uuid] /srv/archive ext4 ro,nodev,nosuid,noexec 0 2
On-Demand Backup Disk
Use noauto to prevent mounting at boot and nofail to avoid boot delays if the disk is absent.
UUID=[uuid] /mnt/backup ext4 noauto,nofail,x-systemd.automount 0 2
Swap Entries
Swap Partition by UUID
This is the standard swap partition entry.
UUID=[uuid] none swap sw 0 0
Swap File
Use this for systems configured with a swap file instead of a dedicated partition.
/swapfile none swap sw 0 0
High-Priority Swap Device
Higher pri values are used first.
UUID=[uuid] none swap defaults,pri=100 0 0
Encrypted Swap Mapper
This is common when the swap device is unlocked through /etc/crypttab.
/dev/mapper/cryptswap none swap defaults 0 0
Encrypted Partitions
For LUKS devices, define the unlock step in /etc/crypttab, then reference the mapper device in /etc/fstab.
crypttab Entry for a LUKS Volume
[mapper_name] UUID=[uuid] none luks
Mount Unlocked LUKS Volume
After unlock, the device appears under /dev/mapper/.
/dev/mapper/[mapper_name] /secure ext4 defaults 0 2
LUKS Volume with Hardened Mount Options
Useful for data partitions that should not allow device files or setuid binaries.
/dev/mapper/[mapper_name] /srv/secure xfs defaults,nodev,nosuid 0 0
Encrypted Logical Volume from LVM
This is common when LVM provides the logical volume and the mapper path is mounted directly.
/dev/mapper/vg0-data /data ext4 defaults 0 2
NFS and NFSv4 Mounts
Use _netdev for network filesystems so systemd waits for networking.
Use nofail when the system should still boot even if the server is unavailable.
Generic NFS Mount
This is a good baseline for a reliable NFS mount.
[server]:[export_path] /mnt/nfs nfs rw,hard,_netdev 0 0
NFS Mount with Explicit Version
Use this when the server supports NFSv4 but you prefer the nfs filesystem type.
[server]:[export_path] /srv/share nfs rw,vers=4.1,hard,_netdev 0 0
Native NFSv4 Mount
This is the direct nfs4 form.
[server]:[export_path] /mnt/nfs4 nfs4 rw,hard,timeo=600,retrans=2,_netdev 0 0
NFSv4 Automount
x-systemd.automount delays the actual mount until first access.
[server]:[export_path] /srv/projects nfs4 rw,hard,noatime,_netdev,x-systemd.automount,x-systemd.idle-timeout=600 0 0
Read-Only NFSv4 Share
Useful for published content, package mirrors, or report exports.
[server]:[export_path] /mnt/reports nfs4 ro,hard,_netdev,nofail 0 0
NFS Home Directories
This pattern is common in labs and shared Linux environments.
[server]:/home /home nfs4 rw,hard,intr,_netdev 0 0
Slow or Optional NFS Server
Reduce boot impact when the share is not critical.
[server]:[export_path] /mnt/optional nfs nofail,_netdev,x-systemd.device-timeout=10s 0 0
Advanced Examples
Bind Mount
Expose one directory tree at another path.
/var/log /srv/chroot/log none bind 0 0
tmpfs for /tmp
Keep temporary files in memory with a size cap.
tmpfs /tmp tmpfs defaults,noatime,mode=1777,size=2G 0 0
Removable Media Mounted by Regular User
Use this for local lab machines or workstations.
UUID=[uuid] /mnt/usb ext4 noauto,user,nofail 0 0
Read-Only ISO Mount
Useful for loop-mounted installation media or appliance images.
/srv/images/debian.iso /mnt/iso iso9660 loop,ro 0 0
Mount by Label
Labels can be easier to recognize than UUIDs in small environments.
LABEL=media /srv/media ext4 defaults 0 2
Useful Mount Options
| Option | Meaning |
|---|---|
defaults | Default read-write mount behavior |
ro | Read-only mount |
rw | Read-write mount |
noauto | Do not mount automatically with mount -a or at boot |
nofail | Do not fail boot if the mount is missing |
user | Allow a regular user to mount |
users | Allow any user to mount and unmount |
noexec | Do not allow direct execution of binaries |
nodev | Ignore device files on the mounted filesystem |
nosuid | Ignore setuid and setgid bits |
_netdev | Mark the filesystem as network-dependent |
x-systemd.automount | Create an automount unit |
x-systemd.idle-timeout=600 | Unmount after inactivity |
x-systemd.device-timeout=10s | Limit wait time for missing devices |
vers=4.1 | Request a specific NFS protocol version |
pri=100 | Set swap priority |
bind | Bind an existing path to another mountpoint |
Testing and Troubleshooting
Mount Everything from fstab
sudo mount -av
Mount One Entry by Mountpoint
sudo mount [mount_point]
Unmount One Entry
sudo umount [mount_point]
Check Active Swap Devices
swapon --show
Check Generated Mounts
findmnt --fstab
Inspect Boot-Time Mount Errors
journalctl -b -p warning
Regenerate systemd Mount Units After Changes
sudo systemctl daemon-reload
Best Practices
Use UUID= or LABEL= instead of raw /dev/sdX names whenever possible.
Use 0 2 for most local ext filesystems and 0 0 for network filesystems, swap, and XFS.
Use _netdev for NFS and other network-backed mounts.
Use nofail for removable disks, optional NAS shares, and anything that should not block boot.
Test with findmnt --verify --verbose and mount -a before rebooting.