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
fix filesystem corruption on reboot/shutdown #3804
fix filesystem corruption on reboot/shutdown #3804
Conversation
Signed-off-by: Matthias Reichl <hias@horus.com>
Thanks, I'll include this in nightly builds starting with |
Good catch. But now /flash and /storage are tried to be unmounted before umount.target too and red error messages are printed on every shutdown. When defining the mounts as "extrinsic" with this patch they are only re-/unmounted finally in systemd-shutdown after all processes have been stopped. I've used your debug.sh shutdown script to verify the behavior. |
@mglae I strongly suspect that if we need to patch systemd then we're doing something utterly wrong Unmounting /storage via umount.target should be fine, all services accessing that should be stopped before (unless some unit dependencies are wrong, in which case these have to be fixed). /flash is indeed problematic as it gets an automatic Creating a flash.mount drop-in that disables default dependencies (and thus removes the Conflicts=umount.target) should work though. In local testing I saw /flash unmount failing (you may need "noram" in current master and 9.2 trees to prevent init copying SYSTEM to RAM). Creating a
Note: I only did some very quick testing with that so far, didn't see any FAIL error during reboot and |
This allows installing drop-ins. Signed-off-by: Matthias Reichl <hias@horus.com>
add drop-in to set DefaultDependencies=no on /flash mount. This removes the Conflicts=umount.target and /flash won't be unmounted by systemd. systemd-shutdown will then later remount it ro and try to unmount it. Signed-off-by: Matthias Reichl <hias@horus.com>
I've added a drop-in for /flash to remove default dependencies - /flash now won't be unmounted via umount.target I also noticed that scripts/install didn't install files in PKG_DIR/system.d recursively, added a fix for that so we can easily add drop-ins if needed |
Tested the drop-in on RPi2 and Generic and no longer seeing a failure when unmounting /flash, so LGTM! |
We are using an uncommon configuration extending the root FS with /flash and /storage. There may be modification needed to make this work. But everything that can be configured does not need to be patched. ;-) The drop-in solution is working fine with systemd 242. The drop-in for /storage is needed too. When booting with |
The unmount error because of journald has been a long outstanding systemd issue systemd/systemd#867 which has finally beein fixed in systemd 243 via this PR systemd/systemd#12230 systemd-journal-flush.service now calls However, there's another issue in LE: as systemd-journal-flush.service only has a dependency on /var (via A quick test with a drop-in for systemd-journal-flush.service (adding /storage to RequiresMountsFor) somewhat worked - that added storage.mount to After=, but not Requires=
Though the dependencies now looked correct (checking with Testing with a simple umount wrapper HiassofT@f1a1eb1 I saw that journald had not closed it's files on /storage by the time umount was called
Even more puzzling, when I added storage.mount to Requires= of the drop in
which shouldn't change anything in terms of systemd unit ordering the failed message hasn't occurred yet. The way LE handles persistent logging to /storage should probably be reworked as it's quite hacky. i.e. use tmpfiles.d to create /storage/log, maybe bind-mount /storage/log to /var/mount and/or setup proper dependencies - that'll be stuff for a separate PR though |
PR with fix for storage unmount failed with debugging enabled is here: #3831 |
On RPi4 I regularly saw that the journal on the /storage partition was corrupted and needed to be recovered on boot, which indicates that the partition wasn't cleanly unmounted before rebooting/shutting down.
Testing with a simple script executed right before reboot showed that both storage (and also flash if it was remounted rw before) wasn't remounted ro or unmounted before reboot - so the filesystem caches were dirty.
Test commit to add mount info before reboot: HiassofT@175c1df
console output - note rw on /storage
This is caused by the bad systemd-0005-ignore-storage-flash-mount-points.patch patch which prevents systemd-shutdown to remount ro and then unmount those two filesystems.
Drop this patch, it's highly probable that it has also been causing the unexplainable kodi database or xml file corruptions that we have been seeing in the last couple of years.
With this PR storage will be properly unmounted and flash remounted as ro before reboot (tested on 4GB RPi4 with noram on cmdline.txt to simulate low-ram devices)
or also flash unmounted if SYSTEM was copied to ram (tested on 4GB RPi4 without noram)