[pkg-cryptsetup-devel] cryptdisks stopper hanging on shutdown for LVM VG

Thorsten Glaser t.glaser at qvest-digital.com
Mon Aug 19 13:26:22 BST 2024


On Fri, 17 May 2024, Thorsten Glaser wrote:

>On shutdown, however, after the fs has been umounted by
>K06umountfs, the K07cryptdisks and K08cryptdisks-early run
>and try to stop the LUKS, which cannot work because the LVM
>is still open on it. It throws a number of “failed” while
>stalling, and then a couple more messages very rapidly before
>powering off.
>
>(On the next boot, my root filesystem had errors from e2fsck,
>so the shutdown may have not been clean.)

It is indeed not clean, the root filesystem gets a journal replay.

>Incidentally, the cryptdisks scripts have lvm2 in Should-Stop
>and X-Stop-After, respectively, so perhaps in the past lvm2
>did stop unused LVs, VGs and PVs on shutdown?

I did some reading and experimenting, and I think this also has
not worked right in the past, for VGs whose PV(s) are on a LUKS
not marked as initramfs in crypttab(5) due to the Should-Stop.

I *did* find something that works for me (patch below), although
it’s not a generic solution: I have to hardcode the VG name of
the “extra” VG on a separate LUKS; there seems to be no method
to ask LVM to just disable all unused VGs. (That would be useful!
Especially for rescue systems as well!) Ideas about that welcome.

My setup has vg-cSD (root) and vg-cSSD (extra), the latter must
be disabled before the cryptdisks initscript stops its PV’s LUKS.

┌──┤ etckeeper diff────────────────────────────────────────────────────┐
--- a/init.d/cryptdisks
+++ b/init.d/cryptdisks
@@ -4,9 +4,9 @@
 # Required-Start:    checkroot cryptdisks-early
 # Required-Stop:     umountroot cryptdisks-early
 # Should-Start:      udev mdadm-raid lvm2
-# Should-Stop:       udev mdadm-raid lvm2
+# Should-Stop:       udev mdadm-raid
 # X-Start-Before:    checkfs
-# X-Stop-After:      umountfs
+# X-Stop-After:      umountfs lvm2
 # X-Interactive:     true
 # Default-Start:     S
 # Default-Stop:      0 6
--- a/init.d/lvm2
+++ b/init.d/lvm2
@@ -2,13 +2,13 @@
 ### BEGIN INIT INFO
 # Provides:          lvm2 lvm
 # Required-Start:    mountdevsubfs
-# Required-Stop:
+# Required-Stop:     cryptdisks
 # Should-Start:      udev mdadm-raid cryptdisks-early multipath-tools-boot
 # Should-Stop:       umountroot mdadm-raid
 # X-Start-Before:    checkfs mountall
 # X-Stop-After:      umountfs
 # Default-Start:     S
-# Default-Stop:
+# Default-Stop:      0 6
 ### END INIT INFO
 
 SCRIPTNAME=/etc/init.d/lvm2
@@ -23,7 +23,12 @@ case "$1" in
 	/sbin/lvm vgchange -aay --sysinit >/dev/null
 	log_action_end_msg "$?"
 	;;
-  stop|restart|force-reload|status)
+  stop)
+	log_action_begin_msg "Stopping LVM Volume Group vg-cSSD"
+	vgchange -a n vg-cSSD
+	log_action_end_msg "$?"
+	;;
+  restart|force-reload|status)
 	;;
   *)
 	echo "Usage: $SCRIPTNAME start" >&2
└──────────────────────────────────────────────────────────────────────┘

Note that this is by no means a patch that should be applied anywhere
at this point (except locally, on bullseye systems matching this setup).
It’s more a base for discussion.

bye,
//mirabilos
-- 
Infrastrukturexperte • Qvest Digital AG
Am Dickobskreuz 10, D-53121 Bonn • https://www.qvest-digital.com/
Telephon +49 228 54881-393 • Fax: +49 228 54881-235
HRB AG Bonn 18196 • USt-ID (VAT): DE274355441
Vorstand: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
Vorsitzender Aufsichtsrat: Peter Nöthen



More information about the pkg-cryptsetup-devel mailing list