Skip to content
linux storage

fstab

fstab mount boot linux storage
Plain English

fstab is a short text file that tells Linux which drives to connect when it starts up and where to put them in the folder tree. Each line describes one drive or partition. Because the system reads it on every boot, one typo can stop the machine from starting, which is why you always test changes before rebooting.

Technical Definition

/etc/fstab (filesystem table) has one line per mount with six fields:

<device>                                  <mount>    <type> <options>       <dump> <pass>
UUID=3f1c9a7e-2b4d-4f8e-9a1c-0d5e6f7a8b9c /          ext4   errors=remount-ro 0     1
UUID=1A2B-3C4D                            /boot/efi  vfat   umask=0077        0     1
/swap.img                                 none       swap   sw                0     0

Fields:

  1. Device: UUID=, LABEL=, or a path. Prefer UUID; /dev/sdX names can change.
  2. Mount point: where it appears in the tree
  3. Type: ext4, xfs, vfat, nfs, swap
  4. Options: defaults, ro, noatime, nofail (do not block boot if missing), x-systemd.device-timeout=10s
  5. Dump: legacy, almost always 0
  6. Pass: fsck order. 1 for root, 2 for others, 0 to skip

At boot, systemd-fstab-generator turns each line into a .mount unit. If a required mount fails, boot drops to emergency mode with root’s shell.

Test before reboot: sudo findmnt --verify checks syntax and devices, and sudo mount -a tries every entry now.

Source: fstab(5) Ubuntu manual page

Adding a disk to fstab safely

# Get the UUID
$ sudo blkid /dev/sdb1
/dev/sdb1: LABEL="data" UUID="7d2e..." TYPE="ext4"

# Back up, then append the line
$ sudo cp /etc/fstab /etc/fstab.bak
$ echo 'UUID=7d2e... /mnt/data ext4 defaults,nofail 0 2' | sudo tee -a /etc/fstab

# Verify before rebooting
$ sudo systemctl daemon-reload
$ sudo findmnt --verify
Success, no errors or warnings detected
$ sudo mount -a && df -h /mnt/data
In the Wild

A bad fstab line is one of the most common self-inflicted boot failures: a typo in a UUID, a disk that was removed, or a network share that is not reachable at boot. Use nofail for anything that is not required to boot, always run findmnt --verify and mount -a before rebooting, and keep a backup copy. If you do land in emergency mode, remount root read-write with mount -o remount,rw /, fix the line, and reboot.