Knowledge

fstab on Ubuntu 24.04: mounting disks safely at boot with UUID and nofail

Updated 2026-11-29 · Present

  • /etc/fstab lists which disk is mounted where at every boot; one bad line can stop the machine from coming up.
  • Use UUID= instead of /dev/sdb1, add nofail for secondary disks, and always test with findmnt --verify and mount -a before rebooting.
  • Keep a copy of fstab and an open SSH session while you edit.

Goal

This article shows how to permanently mount an ext4 file system (created on an LVM volume or an ordinary partition) at /srv/app on Ubuntu 24.04 LTS, so that the machine still boots even when the disk is absent. It explains why a broken fstab is so dangerous and how to test it yourself before rebooting.

Preparation

Warning: a bad line in /etc/fstab can drop the machine into emergency mode at boot, requiring direct console access to fix. For a remote machine with no console, the risk is greater.

Steps

Steps

Step 1: read the structure of a line

Each fstab line has six fields separated by whitespace:

<device>  <mount point>  <type>  <options>  <dump>  <fsck>

Example:

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  /srv/app  ext4  defaults,nofail  0  2

The dump field is usually 0. The fsck field is the order of file system checks at boot: 1 is for the root file system /, 2 for other file systems, and 0 means no check.

Step 2: get the UUID

sudo blkid /dev/vg_data/lv_app
lsblk -f

Names like /dev/sdb1 can change when you add disks or change their order, whereas the UUID is tied to the file system and stays stable. With LVM the /dev/<VG>/<LV> path is also stable, but the UUID is still the consistent choice.

Step 3: add the line to fstab

sudo nano /etc/fstab

Add a line at the end with your real UUID (as in the example above). What the options mean:

Step 4: test before rebooting

sudo findmnt --verify
sudo systemctl daemon-reload
sudo mount -a
findmnt /srv/app

findmnt --verify reads fstab and reports syntax errors, nonexistent UUIDs and missing mount points. daemon-reload reloads the mount units that systemd generates from fstab. mount -a mounts every entry not yet mounted; if it reports an error, fix it right away and do not reboot.

Verification

Only when mount -a succeeds and findmnt /srv/app shows the right device:

  1. Write a test file into /srv/app.
  2. Reboot with sudo reboot while you still have a fallback way in.
  3. After it comes up, run findmnt /srv/app and df -h /srv/app.

If the disk holds data that a service needs, check that the service runs correctly after the mount using systemctl status, as in systemctl on Ubuntu 24.04: enabling, disabling and restarting services and checking their status. With Docker, remember that volume data lives under Docker's data directory by default, so to use a separate disk you must put it in the right place; read Named volumes and bind mounts: where data lives when a container is removed to learn where data lives.

Common errors

Summary

A safe fstab line uses a UUID instead of a device name, nofail for secondary disks, and the routine of findmnt --verify, daemon-reload, mount -a before rebooting. Keep a backup and a fallback way in; most boot problems caused by fstab can be avoided with these three checks.

References