about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAloz1 <kno0001@gmail.com>2017-09-08 02:14:28 +1000
committerEnno Boland <g@s01.de>2017-09-07 18:14:28 +0200
commitd1de64e50fc25d9e43a479c9a74c020daa1281e4 (patch)
tree56695bcf8431805afaeb6523a7e6e786cf14528b
parent00c10ef0c99859c583abc97974616eb278d3f24e (diff)
downloadrunit-void-d1de64e50fc25d9e43a479c9a74c020daa1281e4.tar.gz
runit-void-d1de64e50fc25d9e43a479c9a74c020daa1281e4.tar.xz
runit-void-d1de64e50fc25d9e43a479c9a74c020daa1281e4.zip
deactivate_crypt should not try to close encrypted volumes that are still mounted during shutdown (#75) 20170907
* deactivate_crypt should not try to close encrypted volumes that are still mounted during shutdown.

When shutting down or rebooting a system with full disk encryption (as per https://wiki.voidlinux.eu/install_LVM_LUKS and https://wiki.voidlinux.eu/install_LVM_LUKS_on_UEFI_GPT), deactivate_crypt will irrespectively try and close all encrypted partitions, including '/'. On some systems, (including my own) this causes lockups on shutdown or reboot.

This commit ensures that only encrypted volumes with nothing mounted are closed (which should only be '/' at that point in shutdown).

* Reduced if statement to a one liner
-rw-r--r--functions4
1 files changed, 3 insertions, 1 deletions
diff --git a/functions b/functions
index d1cd318..7f2e38c 100644
--- a/functions
+++ b/functions
@@ -49,7 +49,9 @@ deactivate_vgs() {
 deactivate_crypt() {
    if [ -x /sbin/dmsetup -o -x /bin/dmsetup ]; then
        msg "Deactivating Crypt Volumes"
-       dmsetup ls --target crypt --exec 'cryptsetup close'
+       for v in $(dmsetup ls --target crypt --exec "dmsetup info -c --noheadings -o open,name"); do
+           [ ${v%%:*} -eq 0 ] && cryptsetup close ${v##*:}
+       done
        deactivate_vgs "Crypt"
    fi
 }