Linux – Force fsck check after reboot with single command

arch linuxfscksystemd

I'm looking for systemd's equivalent to the shutdown -F command.
I know that I can force fsck by adding fsck.mode=force to kernel options or tweak mount count for disks.
I have tried touch /forcefsck but it doesn't work with latest systemd versions.

Best Answer

When I want to force fsck, I just use the following command:

# tune2fs -C 50 /dev/sda2

It simply sets the mount counter to 50, but I also have set:

# tune2fs -l
...
Mount count:              18
Maximum mount count:      20

So as you can see, when I set 50 in mount count, kernel thinks it should fsck the partition.

This solution works always, no matter what you use sysvinit/systemd or whatever else.

Related Question