8.2 Persistent Mounts: /etc/fstab, UUIDs & systemd mount units (104.3)
Key Takeaways
- The `/etc/fstab` (File System Table) configuration file defines static filesystem mounting rules evaluated during system boot and when executing `mount -a`.
- Each entry in `/etc/fstab` consists of exactly six whitespace-separated fields: Device Identifier, Mount Point, Filesystem Type, Mount Options, Dump Frequency, and Fsck Pass Order.
- Using persistent identifiers such as `UUID=...` or `LABEL=...` instead of volatile device paths (`/dev/sda1`) prevents boot failures caused by drive reordering during storage controller enumeration.
- The sixth field (`fsck` pass order) dictates boot-time filesystem integrity checking: `1` is reserved exclusively for the root (`/`) filesystem, `2` is used for other local physical filesystems, and `0` disables checks (mandatory for swap, tmpfs, and modern filesystems like XFS and Btrfs).
- Systemd automatically parses `/etc/fstab` at boot using `systemd-fstab-generator`, creating native `.mount` and `.automount` units in `/run/systemd/generator/` using escaped path naming (e.g., `/var/log` becomes `var-log.mount`).
8.2 Persistent Mounts: /etc/fstab, UUIDs & systemd mount units
Quick Summary: Filesystem attachments made manually using the
mountcommand are temporary and do not survive a system reboot. To make mounts persistent, Linux reads the/etc/fstab(File System Table) configuration file during system startup. Every line in/etc/fstabdefines a storage device, its designated mount point, its filesystem type, specific mount options, dump backup scheduling, and filesystem integrity check (fsck) order. Modern Linux distributions convert/etc/fstabentries dynamically into native systemd.mountunits. Mastering/etc/fstabcolumn structure, persistent identifiers (UUID,LABEL), and verification techniques (mount -a) is a core LPIC-1 competency.
1. Anatomy of the /etc/fstab Configuration File
The /etc/fstab file is plain text. Blank lines and lines beginning with a hash mark (#) are treated as comments and ignored by the parser. Each active entry consists of exactly six whitespace-separated columns (spaces or tabs):
# Sample /etc/fstab entry:
# [1. Device] [2. Mount] [3. Type] [4. Options] [5. Dump] [6. Pass]
UUID=4a92c3d1-81f2-4e02-990a-1123456789ab / ext4 defaults,noatime 0 1
UUID=9f8e7d6c-5b4a-3210-fedc-ba9876543210 /home xfs defaults,nodev,nosuid 0 0
LABEL=BACKUP_DATA /mnt/backup ext4 defaults,noauto,user 0 2
/dev/sr0 /media/cdrom iso9660 ro,user,noauto 0 0
/dev/sda3 none swap sw 0 0
192.168.1.50:/exports/data /mnt/nfs nfs _netdev,defaults 0 0
The 6 /etc/fstab Columns Reference Table
| Column | Field Name | Permitted Values & Common Formats | Functional Purpose |
|---|---|---|---|
| 1 | Device / File System | UUID=..., LABEL=..., PARTUUID=..., /dev/sda1, server:/share, tmpfs, proc, none | Identifies the physical block device, network share, or virtual pseudo-filesystem to be mounted. |
| 2 | Mount Point | Absolute directory path (e.g., /, /boot, /home, /var), or none / swap for swap space | Specifies the target directory in the VFS hierarchy where the filesystem will be attached. |
| 3 | Filesystem Type | ext4, xfs, btrfs, vfat, iso9660, swap, nfs, auto | Defines the driver needed to parse the filesystem data structures. |
| 4 | Mount Options | Comma-separated list with no spaces (e.g., defaults, ro, noexec, nosuid, noatime, nofail, _netdev) | Controls operational parameters, permissions, caching, and startup dependencies. |
| 5 | Dump Frequency | 0 (do not dump) or 1 (dump backup enabled) | Used by the legacy dump backup utility to determine if the filesystem needs backup. Almost universally set to 0 on modern systems. |
| 6 | Fsck Pass Order | 0 (no boot check), 1 (checked first; reserved for /), 2 (checked second; other local filesystems) | Dictates the order in which fsck scans and repairs filesystems during boot. |
2. Field-by-Field Technical Breakdown
Field 1: Device Identifiers (UUID vs. LABEL vs. Device Nodes)
Using traditional device paths like /dev/sda1 in /etc/fstab is dangerous in modern systems. When storage hardware changes, controllers reinitialize, or USB drives are inserted, kernel device enumeration order can shift, causing /dev/sda1 to become /dev/sdb1 and leading to boot failure.
To prevent this, Linux supports persistent device naming:
UUID=(Universally Unique Identifier): A 128-bit hex string stored in the filesystem superblock (e.g.,UUID=4a92c3d1-81f2-4e02-990a-1123456789ab). It remains constant even if the drive is moved to another SATA/NVMe port.LABEL=: A human-readable volume label assigned during filesystem creation or via tools likee2labelorxfs_admin -L(e.g.,LABEL=ROOT_OSorLABEL=BACKUP).PARTUUID=/PARTLABEL=: Identifiers stored in the GPT partition table rather than the filesystem superblock.
# Inspect UUIDs and Filesystem Types using blkid:
$ sudo blkid
/dev/sda1: UUID="4a92c3d1-81f2-4e02-990a-1123456789ab" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="000a12bc-01"
/dev/sda2: UUID="9f8e7d6c-5b4a-3210-fedc-ba9876543210" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="000a12bc-02"
# Inspect block devices, UUIDs, and mount points using lsblk:
$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
├─sda1 ext4 1.0 ROOT 4a92c3d1-81f2-4e02-990a-1123456789ab 18.2G 48% /
└─sda2 xfs HOME 9f8e7d6c-5b4a-3210-fedc-ba9876543210 82.4G 12% /home
Field 4: Critical Mount Options in /etc/fstab
defaults: Expands automatically to:rw,suid,dev,exec,auto,nouser,async.nofail: Prevents system boot failure and avoids dropping to emergency mode if the device is disconnected or fails to mount._netdev: Instructs systemd and init scripts to delay mounting until network connectivity is active (mandatory for NFS, iSCSI, and CIFS shares).usrquota/grpquota: Enables user or group disk quota enforcement on ext4/XFS filesystems.
Field 6: Fsck Pass Order Rules (Exam Hotspot)
The sixth column determines how fsck behaves at boot:
1: Root filesystem (/) ONLY. The root filesystem must be checked first before any other services or mounts initialize.2: All other local filesystems requiring boot-time integrity scans (e.g.,/home,/var). All filesystems marked2are checked in parallel across physical spindles.0: Disablefsckscanning. Mandatory for:- Swap partitions (
swap) - Virtual filesystems (
proc,sysfs,tmpfs) - Optical media and ISOs (
iso9660) - Network shares (
nfs,cifs) - Filesystems with internal journal replay engines that do not use
fsckat boot, such as XFS and Btrfs.
- Swap partitions (
⚠️ LPIC-1 Trap — Setting Fsck Pass Order for XFS: XFS has its own built-in metadata journaling and repair mechanisms executed during kernel mount. It does not run traditional
fsckat boot. Setting column 6 to1or2for an XFS filesystem is an error; XFS entries in/etc/fstabshould always have pass order set to0.
3. Safe Workflow for Modifying /etc/fstab
A syntax error in /etc/fstab (such as a missing column, a typo in a UUID, or an invalid mount option) can prevent the system from completing boot, forcing it into an emergency root shell.
Best Practice Procedure:
- Always create a backup before editing:
sudo cp /etc/fstab /etc/fstab.bak. - Add or modify the entry using a text editor.
- Test the configuration immediately without rebooting by executing:
$ sudo mount -a - If
mount -areturns zero errors and mounts the target successfully, the configuration is safe for reboot.
💡 LPIC-1 Exam Fill-in-the-Blank Alert: Which command reads
/etc/fstaband mounts all listed filesystems that do not have thenoautooption, allowing administrators to verify syntax without rebooting? Answer:mount -a
4. systemd Mount Units and systemd-fstab-generator
In modern systemd-based Linux systems, filesystem mounting is managed natively by systemd unit files ending in .mount and .automount.
How systemd Integrates with /etc/fstab
During early boot, systemd invokes an internal binary called systemd-fstab-generator. This tool parses /etc/fstab and automatically generates native .mount unit files inside the transient runtime directory /run/systemd/generator/.
systemd-fstab-generator Workflow:
┌──────────────┐ systemd-fstab-generator ┌────────────────────────────────┐
│ /etc/fstab │ ─────────────────────────────────>│ /run/systemd/generator/ │
└──────────────┘ (Executed at boot) │ ├── var-log.mount │
│ └── home.mount │
└────────────────────────────────┘
Mount Unit Naming Convention (systemd-escape)
Systemd requires that .mount unit filenames strictly match the path of the mount point directory, with leading slashes stripped and all internal slashes replaced by dashes (-):
- Mount point
/→-.mount - Mount point
/home→home.mount - Mount point
/var/log→var-log.mount - Mount point
/srv/web/data→srv-web-data.mount
Administrators can generate properly escaped unit names using the systemd-escape command:
$ systemd-escape --path /var/log
var-log
$ systemd-escape --path --suffix=mount /srv/web/data
srv-web-data.mount
Inspecting and Managing Mount Units via systemctl
# List all active mount units:
$ systemctl list-units --type=mount
# View the status of the /var/log mount unit generated from fstab:
$ systemctl status var-log.mount
# Reload systemd generators after editing /etc/fstab without rebooting:
$ sudo systemctl daemon-reload
An administrator is adding a new local XFS data partition mounted at /data to /etc/fstab. What integer value should be specified in the sixth column (fsck pass order)?
A junior administrator edited /etc/fstab to mount a new secondary NVMe drive. Before rebooting the production server, which command should be executed to verify that the /etc/fstab syntax is valid and mount all configured partitions?
In a systemd-based Linux distribution, which systemd unit name corresponds to a persistent mount point configured at /var/log?