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.
2 Answers
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.
systemd's shutdown -F equivalent is systemctl poweroff. I haven't figured out the relation with fsck. However, AFAIK, you can not force fsck using systemd, because fsck is executed before systemd starts.
- If you add -F flag to shutdown command it will force fsck execution after reboot: unixhelp.ed.ac.uk/CGI/man-cgi?shutdownanlar– anlar2013-12-28 14:37:31 +00:00Commented Dec 28, 2013 at 14:37
- 1It just passes fsck.mode=force to the kernel. With systemd I guess you can't AFAIK.edmz– edmz2013-12-28 14:47:45 +00:00Commented Dec 28, 2013 at 14:47
- 2systemd is init, i.e. the very first program executed, so fsck necessarily takes place after systemd is run.psusi– psusi2015-01-01 04:56:40 +00:00Commented Jan 1, 2015 at 4:56
fsck.mode=forceis indeed your only option wiki.archlinux.org/index.php/fsck#Forcing_the_check