How to set systemd
for automatically force fsck
disks after crash (hard poweroff)?
When I used sysvinit
(in Arch Linux) as /sbin/init
I used the hack: in the rc.local
I create /forcefsck
file; in the rc.local.shutdown
I remove it. At boot-up rc.sysinit
enable force fsck if /forcefsck
exists.
How to do same in systemd
? Maybe it has built-in facilities for automatic fsck
after crush?
Best Answer
You can force
fsck
at boot time by passingfsck.mode=force
(auto
is default andskip
can be used to skip checking at all) as a kernel command line parameter (as ofsystemd
v. 213, there's also a second parameter:fsck.repair
- to control howfsck
shall deal with unclean file systems at boot; possible values are:preen
to fix what can be safely fixed,yes
to answer yes to all questions andno
is default).Note that
systemd-fsck
does not know any details about specific filesystems, and simply executes file system checkers specific to each filesystem type (/sbin/fsck.*
).Now, if your filesystem is
xfs
orbtrfs
it will execute/sbin/fsck.xfs
or/sbin/fsck.btrfs
respectively. If that does not seem to work maybe you should check the manual page forfsck.xfs
orfsck.btrfs
respectively and examine the contents of the said files in/sbin
.