GrepBoard/Manuals
605 manuals ·

Verify fstab with findmnt before you reboot

·Tested on Ubuntu 24.04.5 LTS · util-linux 2.39.3 (findmnt)·Test scope ↓·8 steps

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.

console
# findmnt --verify

[2] Test edits on a copy first. --tab-file points the check at another file.

console
# 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.

fstab.test
# <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
console
# 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-eeeeeeeeeeee

The 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.

OutputMeaningFix
unreachable on boot required source: UUID=…No device has that UUIDCompare with blkid
unreachable on boot required target: No such file or directoryThe mount point directory is missingmkdir -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.

console
# 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.

console
# 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.

console
# 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.

console
# cp /etc/fstab /root/fstab.bak# cp /tmp/fstab.new /etc/fstab# findmnt --verify# mount -a

If a mounted disk then runs short of space, see Find what is filling a full disk.

#fstab#findmnt#mount#boot