0

We have a Raspberry Pi located at a location where it may experience frequent power loss. I'm trying to make it scan, and repair (if necessary) a filesystem every time it boots up, in case the power loss causes FS corruption. The filesystem in question is ext4, but it is NOT the root filesystem.

It seems that I can do what I want by using tune2fs -c 1 /dev/sdX#, and setting /etc/fstab's Filesystem Check Order to 2 for that partition. What I'm not sure about is what it does when it detects problems. Does this automatically fix them? Will it stop booting, and wait for someone to confirm that it should fix things?

The Pi is headless - there's no one to confirm anything.

1

You don't need to set "-c 1" on the filesystem. That means "force a full e2fsck run each mount", which would both be annoying (slow boot time), and unnecessary for ext4 with a journal. Even without a journal you don't strictly need to run a full e2fsck if the filesystem has been cleanly unmounted (it will record this into the superblock itself).

By default, if there is a check phase in /etc/fstab then e2fsck will repair the filesystem automatically. Per the e2fsck.8 man page, the default is to run with "-p", though "-y" is more aggressive in fixing problems automatically.

  • I tested this. Setting "-c 1" on the filesystem did not noticeably increase boot time. Also, it's a headless system - there's no one around for the boot process to annoy, even if it took several minutes (which it doesn't). If forcing a full e2fsck run each mount even slightly increases the chance of recovering from filesystem corruption, it's worth it for us as there's no downside I can see that we care about. Is there any way to make e2fsck use "-y" when it gets run by the system automatically? – Tal Oct 26 '18 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.