Mechanisms that trigger `fsck` on boot
Question: Which mechanisms (other than the one in /etc/fstab
) automatically trigger fsck
at the boot?
Details: My computer currently runs Ubuntu 21.04 without any issues, it works properly. At the boot, a fsck
disk check is performed, because I see the following lines on my screen.
Ubuntu: clean, 281400/3276800 files, 3602929/13107177 blocks
where Ubuntu
is the label for my /dev/sda2
(the root partition). However, if you ckeck my /etc/fstab
file, the last column (that is the column used by fsck to determine whether fsck should check filesystem before it is mounted) is set to zero, therefore I don't expect any check at the startup.
# <file system> <mount point> <type> <options> <dump> <pass>
# /dev/sda1
UUID=DA59-E469 /boot/efi vfat defaults 0 0
# /dev/sda2
UUID=862c6f26-cbe0-4cd5-860d-fdf306f697f9 / ext4 noatime,errors=remount-ro 0 0
# /dev/sda3
UUID=70f175d4-ec37-455c-84c5-b93d1e2e8761 /mnt/Data ext4 noatime,nosuid,nodev,nofail,x-gvfs-show 0 0
# swapfile
/swapfile none swap sw 0 0
I'm just curious to understand how the check is triggered (and/or if there's something wrong im my assumptions).
Some details:
- I used same
/etc/fstab
in Ubuntu 20.04 and Ubuntu 20.10. The check started to appear after the update to Ubuntu 21.04: nofsck
check in 20.04 and 20.10 boot. - Output of
sudo tune2fs -l /dev/sda2 | grep checked
isLast checked: Sun Apr 26 15:00:01 2020
, that is probably when I set the last column of/etc/fstab
to zero. - I don't have any
/forcefsck
file on root. - In my
/etc/default/grub
there is NOfsck.mode=force
setting.
A file system check on startup is triggered by systemd services. There are , systemd-fsck-root.service
and [email protected]
for the root file system and other partitions, respectively. These services continue to use the traditional passno, i.e., the number on the sixth field in /etc/fstab
, to determine if and in what order announced file systems should be checked.
According to man systemd-fsck
:
These services are started at boot if passno in /etc/fstab for the file
system is set to a value greater than zero. The file system check for
root is performed before the other file systems. Other file systems may
be checked in parallel, except when they are on the same rotating disk.
However, root appears to be treated specially. It is checked earlier on in the boot process, in initramfs. As stated in the documentation, systemd-fsck-root.service
only kicks in when the check did not proceed there. Else, its status will be revealed as "failed".
So probably, you would see effect of changing passno in /etc/fstab
if you changed it for a partition other than the root partition.
That your output of tune2fs
is indicating a check long ago is due to the fact that only thorough file system checks are registered. By default, a file system check of journaling ext file systems is limited to checking what the journal reports. In former Ubuntu versions, a max-mount-count
of 30 was set, indicating that a full file system check would be forced after every 30 mounts. Currently, this is set to -1
, so the file system is never fully checked unless the journal reports an issue.