FS#18736 - [initscripts] shutdown: fsck
Attached to Project:
Arch Linux
Opened by Matteo Sasso (m.sasso) - Thursday, 18 March 2010, 13:32 GMT
Last edited by Tom Gundersen (tomegun) - Thursday, 23 June 2011, 13:25 GMT
Opened by Matteo Sasso (m.sasso) - Thursday, 18 March 2010, 13:32 GMT
Last edited by Tom Gundersen (tomegun) - Thursday, 23 June 2011, 13:25 GMT
|
Details
Every distro tries to make the boot process quick and
painless. Periodical filesystem checks, although relatively
rare, can take a long time on some systems.
This patch checks all filesystems at shutdown. Startup checks are only performed following an unclean shutdown. The patch remounts the root filesystem BEFORE disabling encryption and LVM. I tested the patch in an encrypted system but not on LVM. LVM might complain a little but should work anyway. This is necessary because root must be mounted read-only before checking, and encrypted/LVM filesystems must be available. shutdown_fsck must be placed under /etc/rc.d/functions.d/ and it's just a copy of what's in rc.sysinit. |
This task depends upon
Closed by Tom Gundersen (tomegun)
Thursday, 23 June 2011, 13:25 GMT
Reason for closing: Implemented
Additional comments about closing: It should now be possible to make hooks to implement this feature.
Thursday, 23 June 2011, 13:25 GMT
Reason for closing: Implemented
Additional comments about closing: It should now be possible to make hooks to implement this feature.
With that in mind, a couple of things:
a) Could you make this work in BOTH cases via a rc.conf variable? That would allow us to keep the current behavior, bt have users turn on a "fsck on shutdown" flag if they want
b) As this is a full patch, I'd recommend putting the shutdown_fsck stuff in /etc/rc.d/functions itself
c) How does this behave when using pm-suspend or pm-hibernate? It's worth a test, if you ask me
You could add something like the following:
#
# SHUTDOWN_FSCK: Check all filesystems at shutdown (if needed),
# to make startup time more uniform.
#
SHUTDOWN_FSCK="yes"
b) It probably doesn't belong to /etc/rc.d/functions either since it's used just in one place. In rc.sysinit, the fsck code is just pasted inline so I did something similar with rc.shutdown. I'm attaching a new patch which does away with the shutdown_fsck file.
c) I believe pm-suspend and pm-hibernate don't actually go through the shutdown process. I tried pm-suspend and it works correctly.
Thanks for your comments.
I didn't compare though - is it the same code?
Error handling is done differently because:
I) When a reboot is needed we don't reboot, we just halt
II) When a fatal error occurs we don't want to be dumped to a shell: the shutdown might be unattended, while a bootup, usually, is not.
Would you mind adding a git patch against the initscripts tree that includes an addition of the value to rc.conf with a little documentation (default it to off or commented out or something)
http://projects.archlinux.org/initscripts.git/
Thomas, do you see anything wrong with this patch?
If we could somehow reduce the code duplication a bit, it would be nice.
@Kurt: thanks for the hint.
* provide variable fsckret to the hooks as before
* use a local variable (or maybe just set it and simply drop return and fsckret assignments after calling?)
* run the postfsck hook right after stat_fail/stat_done instead of outside
* use correct hook names ${0##*/rc.}_prefsck and ${0##*/rc.}_postfsck (or should we simply rename the hooks to 'prefsck' and 'postfsck'?)
On shutdown there is a 20 minutes sleep when fsck fails. Isn't that a bit long?
* NETFS is needed for mount too.
This patch on top of the previous would add it:
Also, 20m were meant to be 20s.
Other than this, your patches look good to me.
Thomas, would you mind reviewing, in case I missed anything?
Give me a thumbs up and I'll merge these
edit: Added a patch to avoid duplicate fsck when forced.
0002-Add-support-for-fsck-on-... (4.4 KiB)
0003-Avoid-additional-fsck-on... (1 KiB)
I have now looked at your patches, and while I don't like the idea of fsck on shutdown, I _do_ like the patches ;-)
This is what I propose:
I will accept patches that move split up and move all our fsck stuff into functions (essentially your first patch, without adding new hooks, and without changing rc.shutdown).
I will also accept a patch to make it possible to not fsck on boot (preferable via a kernel command line argument, and preferably something that has been used by someone else before, so we don't introduce new stuff).
Finally, I'd be happy to add one new hook if needed to rc.shutdown.
That should allow the people who want to use this functionality to add a hook file (something for AUR?), and to boot with the correct kernel parameter.
What do you think? Is there still interest in this?
0002-Simplify-fsck-functions.... (1.8 KiB)
0003-Allow-custom-fsck-on-shu... (1.8 KiB)
0004-Move-mount-a-into-functi... (1.5 KiB)