Verify fstab with findmnt before you reboot
Use findmnt --verify to catch missing UUIDs and mount points in fstab before a reboot. It misses mistyped options and a missing nofail, so check those by hand.
A bad line in /etc/fstab bites at the next reboot. findmnt --verify only reads the file and checks each line without mounting anything, so you can run it first.
[1] Check the real file, read-only. With no argument it verifies /etc/fstab.
# findmnt --verify[2] Test edits on a copy first. --tab-file points the check at another file.
# cp /etc/fstab /tmp/fstab.new# vi /tmp/fstab.new# findmnt --verify --tab-file /tmp/fstab.new[3] Here is a test file to learn the output. It has two UUIDs that do not exist (one with nofail), one missing UUID with noauto, a device path that does not exist, and a mount point directory that does not exist.
# <file system> <mount point> <type> <options> <dump> <pass>UUID=11111111-2222-3333-4444-555555555555 /mnt ext4 defaults 0 2UUID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee /media ext4 defaults,nofail 0 2UUID=bbbbbbbb-bbbb-cccc-dddd-eeeeeeeeeeee /srv ext4 defaults,noauto 0 2/dev/sdz1 /opt xfs defaults 0 0UUID=cccccccc-bbbb-cccc-dddd-eeeeeeeeeeee /mnt/nodir ext4 defaults 0 2# findmnt --verify --tab-file fstab.test0 parse errors, 4 errors, 3 warnings/mnt [E] unreachable on boot required source: UUID=11111111-2222-3333-4444-555555555555/media [E] unreachable on boot required source: UUID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/srv [W] unreachable: UUID=bbbbbbbb-bbbb-cccc-dddd-eeeeeeeeeeee/opt [W] unreachable source: /dev/sdz1: No such file or directory [W] cannot detect on-disk filesystem type (No such file or directory)/mnt/nodir [E] unreachable on boot required target: No such file or directory [E] unreachable on boot required source: UUID=cccccccc-bbbb-cccc-dddd-eeeeeeeeeeeeThe first line is the total. Below it, problems are grouped by mount point: [E] is an error, [W] a warning.
[4] The two [E] messages are the ones that block boot.
| Output | Meaning | Fix |
|---|---|---|
unreachable on boot required source: UUID=… | No device has that UUID | Compare with blkid |
unreachable on boot required target: No such file or directory | The mount point directory is missing | mkdir -p it |
[5] nofail does not downgrade the [E]. The /media line above shows it. If that line is intentional (a removable disk), treat the error as expected. A line with noauto, like /srv, gets only a [W]. To see why, name the mount point and add --verbose.
# findmnt --verify --verbose --tab-file fstab.test /srv0 parse errors, 0 errors, 1 warning/srv [ ] target exists [ ] userspace options: noauto [W] unreachable: UUID=bbbbbbbb-bbbb-cccc-dddd-eeeeeeeeeeee[6] Two things findmnt does not catch. First, mistyped options. defualts for defaults and sizee for size both pass.
# cat fstab.typotmpfs /mnt tmpfs defualts,sizee=1m 0 0# findmnt --verify --tab-file fstab.typoSuccess, no errors or warnings detected--verbose lists options as FS options and userspace options but does not judge whether they are valid. Read the options once more yourself.
Second, a missing nofail. A removable-disk line without nofail raises no warning. findmnt cannot know whether a disk may be absent at boot, so check external disks and NFS lines for nofail by hand.
[7] A line with too few fields is a parse error and is ignored. A line with extra text after six fields was not an error in the same test.
# findmnt --verify --tab-file fstab.shortfindmnt: fstab.short: parse error at line 2 -- ignored 1 parse error, 1 error, 0 warnings/mnt [E] unreachable on boot required source: UUID=11111111-2222-3333-4444-555555555555[8] When the copy is clean, install it and check once more. To try the real mounts without rebooting, use mount -a.
# cp /etc/fstab /root/fstab.bak# cp /tmp/fstab.new /etc/fstab# findmnt --verify# mount -aIf a mounted disk then runs short of space, see Find what is filling a full disk.