Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to force fsck on reboot #1801

Open
dmtucker opened this issue Mar 4, 2020 · 9 comments
Open

Unable to force fsck on reboot #1801

dmtucker opened this issue Mar 4, 2020 · 9 comments
Labels

Comments

@dmtucker
Copy link

dmtucker commented Mar 4, 2020

I can't figure out how to run fsck on /. I've tried:

  • fsck.mode=force on the kernel command line (i.e. pressing e before clear boots)
  • sudo tune2fs -C 70 -c 1 /dev/sda3 && reboot
  • sudo tune2fs -i 1m /dev/sda3 && reboot (the last run was over a year ago according to tune2fs)

I'm on 32510.

@ahkok
Copy link
Contributor

ahkok commented Mar 4, 2020

Thanks for reporting - this is really strange...

@thiagomacieira
Copy link

fsck should be triggered by systemd and I've never seen it do that.

If you need a one-off, I suggest booting the system in emergency mode. You'll get to the shell before systemd remounts your root read-write. I don't think periodic fsck is supported any more.

@dmtucker
Copy link
Author

dmtucker commented Mar 4, 2020

Ah, GTK... I was able to work around using the live desktop image on a USB, FWIW.

One thing I didn't try was creating an /etc/fstab (does fsck require that?)... I don't have one, but I've read there are metrics in there that fsck uses to tell which partitions to check.

@thiagomacieira
Copy link

One of the fields in fstab is the scan frequency. Without an fstab, you get autogenerated ones from systemd, which will probably have frequency 0. With an fstab, it'll parse and generate from your choices.

@ahkok ahkok removed the new label Mar 5, 2020
@ahkok
Copy link
Contributor

ahkok commented Mar 5, 2020

@thiagomacieira is correct, and man systemd.fsck confirms this in part - you need to create /etc/fstab entries with the proper frequency set to a non-zero value in order for the fsck.mode thing to work.

@dmtucker
Copy link
Author

dmtucker commented Mar 5, 2020

Interesting, looks like it's actually the order to check in 🤔
I suppose that's how tune2fs fits into this: Systemd decides when to check according to tune2fs, and it checks in the order specified in /etc/fstab?

@random-user-00
Copy link

random-user-00 commented Nov 25, 2020

There is a systemd unit for it: systemd-fsck-root.service
But the question is, how to enable it?

$ sudo systemctl cat systemd-fsck-root.service 
#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=File System Check on Root Device
Documentation=man:systemd-fsck-root.service(8)
DefaultDependencies=no
Conflicts=shutdown.target
Before=local-fs.target shutdown.target
ConditionPathIsReadWrite=!/

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-fsck
TimeoutSec=0

I believe it is supposed to be a part of correct target, but not able to figure out which.
I tried to enable it at local-fs-pre.target and basic.target, but fsck didn't run because of condition ConditionPathIsReadWrite=!/. Then I commented that condition and fsck did run during boot but complained about systemd-fsck[344]: Root directory is writable, skipping check.

@MikhailRokhin
Copy link

Confirm at

Linux 5.10.113-64.lts2020 #1 SMP Wed Apr 27 06:05:02 PDT 2022 x86_64 GNU/Linux

$ sudo swupd info --verbose

Distribution: Clear Linux OS
Installed version: 36640 (format 30)

@bernimoses
Copy link

bernimoses commented Feb 16, 2023

For me changing the correct kernel line in /boot/syslinux.cfg from ... rw to ... ro fsck.mode=force (to read-only mount first and do the fsck) and adding the option rw to the root partition (to read-write mount after the check is done) in /etc/fstab did the trick. Not sure why syslinux is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants