Score:3

Mechanisms that trigger `fsck` on boot

gr flag

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: no fsck check in 20.04 and 20.10 boot.
  • Output of sudo tune2fs -l /dev/sda2 | grep checked is Last 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 NO fsck.mode=force setting.
heynnema avatar
ru flag
You shouldn't disable disk testing in your /etc/fstab.
Score:6
cn flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.