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: the last number on an fstab line decides whether fsck checks that disk

Disk
~/tips/tip-disk-fstab-passno-sixth-field

UUID=<root-uuid> / ext4 defaults 0 1

Explains the sixth fstab column, which decides whether a disk gets a filesystem check at boot.

Most fstab lines end in two numbers, and people copy them from somewhere without a second look. The fifth is for the old dump backup tool. The sixth, fs_passno, tells fsck whether and in which order to check the filesystem at boot, and it’s worth setting on purpose.

UUID=&lt;root-uuid&gt;   /          ext4  defaults  0  1
UUID=&lt;data-uuid&gt;   /mnt/data  ext4  defaults  0  2
192.168.1.x:/export /mnt/nas   nfs   defaults  0  0

The fstab man page gives the rule: 1 for the root filesystem, 2 for other filesystems you want checked, and 0 (also the default when the field is missing) for no check. A network share like the NFS line gets 0, because there’s nothing for the local machine to check.

On a systemd machine, though, the number is mostly a yes or no. systemd-fstab-generator treats passno as a boolean and throws the ordering away, except that root is still checked first. Other filesystems may then be checked in parallel, unless they’re on the same rotating disk. So a 3 doesn’t make a disk wait for the ones marked 2.

A 2 also doesn’t mean a full check at every boot. systemd-fsck runs the checker for that filesystem type, and that checker decides whether a check is needed, for example after an unclean shutdown or once a set number of mounts has passed.

One caveat for XFS. Its fsck.xfs simply exits with success, because XFS replays its journal at mount time, so a 2 on an XFS line does nothing. To really check an XFS filesystem you’d run xfs_repair on it while it’s unmounted. For ext4 data disks I’d use 2, for XFS and network shares 0.

Further reading: fstab(5) manual page, [email protected](8) manual page, fsck.xfs(8) manual page

More Disk tips sudo e2freefrag /dev/sdb1 sudo smartctl -a --json /dev/sda | jq '.smart_status.passed' lsscsi -s udisksctl power-off -b /dev/sdX du -sh — .[!.]* * 2>/dev/null | sort -h All Disk tips (44) All topics

Link