devutils/ATFQ/book ATFQ git

Part II · Your system

13.5 fstab and mount options

alsofstab/etc/fstabmountmount optionsumountnofailnoatimeautomount

TL;DR

  • /etc/fstab lists what to mount at boot, one line per filesystem: what, where, type, options, then two numbers.
  • Name disks by UUID=… (from lsblk -f), not /dev/sdb1: device names can change from one boot to the next.
  • Test a new line before rebooting: sudo mount -a mounts everything listed that isn't mounted yet.
lsblk -f
sudo mount -a
sudo findmnt --verify      # checks fstab for mistakes

On your machine

alice@laptopexample
$ atfq 13.5
  Entries   / (btrfs, subvol=@,noatime) from
            UUID=3f1c2a9e-8b7d-4e21-9c55-0a6b2d7e9f10 · mounted
            /boot/efi (vfat, umask=0077) from UUID=7A2C-1F3B · mounted
            none (swap, defaults) from /swapfile · swap
            /mnt/nas photos (nfs, noauto,nofail) from nas:/photos · NOT
            mounted

An example: Alice's laptop, one of the test machines. In your terminal, this block shows your own machine, read live.

Pitfalls

Deep dive 2 questions

What do the two numbers at the end mean?

The fifth field was for dump, an old backup tool: use 0. The sixth sets the order of filesystem checks at boot: 1 for the root filesystem, 2 for the others, 0 to skip. btrfs and XFS check themselves, so they use 0.

Who reads fstab today?

On systemd systems, a generator turns every line into a .mount unit at boot and at each daemon-reload. That's why systemd options work there: x-systemd.automount mounts on first access, and x-systemd.device-timeout=10s limits how long boot waits for a disk.

Commands
mount findmnt lsblk blkid
Paths
/etc/fstab
See also
14. Disk
13.6 /dev and udev
22.1 Units and timers