Managing /etc/fstab
/etc/fstab (file systems table) controls which file systems are automatically mounted at boot and with what options. A wrong entry in fstab can prevent the server from booting. Understanding the format, knowing how to test changes safely, and knowing how to recover from a broken fstab are critical skills for any Ubuntu administrator.
fstab format explained
/etc/fstab column structure
# <device> <mount_point> <type> <options> <dump> <pass>
UUID=abc123... / ext4 defaults 0 1
UUID=def456... /home ext4 defaults,noatime 0 2
UUID=789abc... /data xfs defaults,noatime 0 2
UUID=ghi012... none swap sw 0 0
tmpfs /tmp tmpfs defaults,nosuid 0 0
//nas/share /mnt/nas cifs credentials=... 0 0
| Column | Name | Values |
|---|---|---|
| 1 | Device | UUID=..., LABEL=..., /dev/sdXN, server:/path |
| 2 | Mount point | Directory path, or none for swap |
| 3 | Type | ext4, xfs, btrfs, swap, tmpfs, nfs, cifs, auto |
| 4 | Options | Comma-separated list (see below) |
| 5 | Dump | 0 = skip dump backup, 1 = include (rarely used) |
| 6 | Pass | 0 = no fsck, 1 = root only, 2 = other partitions |
Mount options reference
| Option | Effect | Use when |
|---|---|---|
defaults | rw, suid, dev, exec, auto, nouser, async | General use |
noatime | Don’t update access time on reads | All servers (reduces writes, improves performance) |
ro | Read-only mount | ISO images, read-only NFS exports |
noexec | Prevent execution of binaries | /tmp, /var/tmp (security) |
nosuid | Ignore suid/sgid bits | /tmp, data volumes (security) |
nodev | Ignore device files | Data volumes (security) |
_netdev | This is a network device; wait for network before mounting | NFS, CIFS mounts |
nofail | Don’t fail boot if this mount fails | Optional removable drives |
Common fstab examples
Production server fstab with security hardening
# System root
UUID=a1b2c3d4-... / ext4 defaults,noatime 0 1
# Home directories
UUID=e5f6g7h8-... /home ext4 defaults,noatime 0 2
# Data volume (XFS)
UUID=i9j0k1l2-... /data xfs defaults,noatime 0 2
# Temporary files (hardened)
tmpfs /tmp tmpfs defaults,nosuid,nodev,noexec 0 0
tmpfs /var/tmp tmpfs defaults,nosuid,nodev,noexec 0 0
# Swap
UUID=m3n4o5p6-... none swap sw 0 0
# NFS share (waits for network, non-fatal if unavailable)
192.168.1.10:/exports/data /mnt/nfs nfs defaults,_netdev,nofail 0 0
Testing and validating fstab
# ALWAYS test before rebooting — a bad fstab can prevent boot
# Step 1: Create the mount point directory
sudo mkdir -p /data
# Step 2: Test mounting all fstab entries
sudo mount -a
# Step 3: Verify the mount succeeded
df -h /data
mount | grep /data
# Step 4: Check for errors
sudo systemctl daemon-reload
sudo systemctl --failed # Check for failed mount units
Recovering from a bad fstab
# If the server does not boot due to a bad fstab entry:
# 1. Boot into recovery mode (GRUB → Advanced → Recovery mode)
# 2. At the recovery menu, choose "Root shell"
# 3. Remount root as read-write
mount -o remount,rw /
# 4. Fix /etc/fstab
nano /etc/fstab
# or restore from backup:
cp /etc/fstab.bak /etc/fstab
# 5. Test
mount -a
# 6. Reboot
systemctl reboot
💡 TIP: Before every fstab edit, make a backup:
sudo cp /etc/fstab /etc/fstab.bak. Keep a copy of the working fstab in a separate location (git repository, configuration management, documentation). A bad fstab is one of the most common causes of server boot failures, and having the backup means a 30-second fix instead of a 30-minute recovery.
Conclusion
The most important fstab rules: use UUIDs (not device names), always test with sudo mount -a before rebooting, and always keep a backup of your working fstab. Add noatime to all non-root mount points to reduce unnecessary writes. Add nosuid,nodev,noexec to /tmp and data volumes for security hardening. Use _netdev and nofail for network mounts so a network outage does not prevent the server from booting.
FAQ
Is Managing /etc/fstab important for Ubuntu administrators?+
Yes. It supports practical Ubuntu administration because it connects directly to server reliability, security, troubleshooting, or daily operations.
Should I practice this on a live server?+
Use a lab VM first. After you understand the command output and rollback path, apply the workflow carefully on real systems.
What should I do after reading this article?+
Run the practice commands, write down what each one shows, and continue to the next article in the Ubuntu roadmap.
Need help with Ubuntu administration?
Work directly with Muhammad Irfan Aslam for Ubuntu Server, Linux, cloud, Docker, DevOps, CI/CD, or infrastructure troubleshooting support.
Hire Me for Support