Linux Labs

Storage / Stage 4 of 11

Partition, filesystem, mount

Not running Starting usually ~20 s
Leave the lesson

Step 4 of 7 · theory · 5 min

An fstab entry with nofail

A partition mounted with mount is gone after a reboot. Here is how to put it in fstab so that a missing disk does not stop the boot.

The partition's line goes into /etc/fstab with the same six fields as in the mounting lesson. The source is UUID= from blkid: a name like /dev/loop0p1 or /dev/vdb1 depends on the order in which disks are attached.

text
UUID=3b2147c3-…  /srv/data  ext4  defaults,nofail  0  2

The nofail option is for data disks. Without it every line of the table is required for boot: the system waits a minute and a half for the device and, if it never shows up, stops in emergency mode, and someone has to get to the console. With nofail the system boots without the disk. The root / is never marked this way: without it the system has nothing to run from.

Checking does not need a reboot:

bash
sudo systemctl daemon-reload          # systemd rereads fstab
sudo findmnt --verify                 # check without mounting
sudo umount /srv/data; sudo mount -a  # unmount and mount again

Without daemon-reload, systemd keeps the old table in mind, and findmnt --verify warns: your fstab has been modified, but systemd still uses the old version. If the partition is back in the directory after mount -a, the entry is correct.

Check yourself 1 question

The data disk was removed from the server, but its /etc/fstab line with the options defaults stayed. What happens at the next boot?

  • The root is mounted at /, and the /srv/data line has nothing to do with it. The source from the line will not be found, and the mount fails.

  • People edit the table: systemd reads it at boot and changes nothing in it.

  • That is how a system with a nofail line boots. Without the option the disk is required: the system waits for it and drops into emergency mode.

Without nofail every fstab line is required for boot. When the device never shows up, the system stops in emergency mode and waits for someone at the console; with nofail it boots without the disk.

Key points

  • A partition goes into fstab by its filesystem UUID: after a reboot the device name may belong to another disk.
  • nofail lets the system boot without a data disk; without the option a missing disk stops the boot.
  • You check the entry without a reboot: daemon-reload, then umount and mount -a.
Ubuntu 24.04
Loading…