brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: nofail in fstab lets Linux finish booting when an extra disk is missing

Linux
~/tips/tip-mounts-fstab-nofail-boot

UUID=1234-abcd /mnt/backup ext4 defaults,nofail,x-systemd.device-timeout=5s 0 2

Marks an fstab mount as optional, so a missing disk no longer holds up the boot.

An external or backup disk in /etc/fstab is a small bet that the disk is plugged in at every boot. When it isn’t, I’d rather the machine still comes up. That is what nofail is for.

UUID=1234-abcd  /mnt/backup  ext4  defaults,nofail,x-systemd.device-timeout=5s  0  2

The line above is an example with a made-up UUID. The nofail option comes from the mount man page: do not report errors for this device if it does not exist.

Under systemd it also changes how the boot waits. The systemd.mount docs say that with nofail the mount is only wanted, not required, by local-fs.target or remote-fs.target, and it is not ordered before them. The boot continues without waiting for the mount unit, whether or not the mount point can be mounted. That option has been there since systemd 215.

Pair it with x-systemd.device-timeout=. It sets how long systemd waits for the device to show up before it gives up on that fstab entry. Give it seconds, or a unit such as s, min or h. The docs add that it only works in /etc/fstab and is ignored in a unit file.

After editing, findmnt --verify checks the fstab for mistakes, which beats finding out at the next boot.

The caveat is easy to miss. When the disk is absent the mount point is just an empty folder on the root filesystem. A container or script that writes to /mnt/backup then fills the system disk without any error. I’d use nofail for extra data and backup disks only, and leave it off for anything the system needs to run, such as the root filesystem.

Further reading: systemd.mount(5) man page, mount(8) man page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link