Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท Special Files and Directories

The /etc/fstab file

Reference for /etc/fstab: the six fields, device identifiers such as UUID, common mount options, dump and fsck pass numbers, and how to test changes safely.

/etc/fstab (file systems table) lists the filesystems and swap areas that should be mounted at boot, and the options for each. mount -a and systemd read it at startup. A short form also helps day to day: if a mount point is listed here, mount /data needs no further arguments.

Each non-comment line has six whitespace-separated fields. A bad line can stop a server from booting normally, because a missing required filesystem drops systemd into emergency mode. Always test a change before you reboot.

Terminal
UUID=3f2a-9c10  /data  ext4  defaults,noatime  0  2

Try it

Bash Reading the mount table

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Splitting fstab lines into fields

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Field Description
1. device What to mount: UUID=..., LABEL=..., PARTUUID=..., a path like /dev/sdb1, a network share (host:/export), or a pseudo name such as tmpfs. UUIDs survive device renumbering, so prefer them.
2. mount point An existing directory. Swap uses none.
3. type ext4, xfs, btrfs, vfat, nfs, cifs, tmpfs, swap or auto.
4. options Comma-separated; defaults means rw,suid,dev,exec,auto,nouser,async.
5. dump 1 lets the old dump backup tool include it; almost always 0.
6. pass fsck order at boot: 1 for the root filesystem, 2 for others, 0 for none.

Spaces in a path are written as \040. Find identifiers with blkid or lsblk -f; see blkid.

Usage notes

  • Test before reboot: sudo mount -a mounts everything not mounted and reports errors, findmnt --verify checks the syntax and device names. See findmnt.
  • Safety options: nofail lets the boot continue if the device is absent (external drives); noauto skips it at boot; x-systemd.automount mounts on first access.
  • Network filesystems need _netdev so they are mounted after the network is up.
  • Hardening: nosuid,nodev,noexec on /tmp or upload partitions blocks several classes of attacks.
  • noatime avoids a write for every read; relatime (the default) is already a good compromise.
  • After editing, systemd generates units from the file; run sudo systemctl daemon-reload so it notices.
  • Details of options are on the fstab options page.
  • Docker containers, like this sandbox, have a nearly empty file because the runtime sets up mounts itself.