From d1de64e50fc25d9e43a479c9a74c020daa1281e4 Mon Sep 17 00:00:00 2001 From: Aloz1 Date: Fri, 8 Sep 2017 02:14:28 +1000 Subject: deactivate_crypt should not try to close encrypted volumes that are still mounted during shutdown (#75) * 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 --- functions | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 } -- cgit 1.4.1