From b780ac75ae490e4725a23e84595e9e5adbbe9db2 Mon Sep 17 00:00:00 2001 From: primardj Date: Tue, 23 Jan 2024 17:28:42 +0000 Subject: [PATCH] improve umount mecanism --- dmount | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/dmount b/dmount index f9a34ed..10258a2 100755 --- a/dmount +++ b/dmount @@ -22,7 +22,7 @@ Mountpoint_data=/home/primardj/data force_remove_vgdevice() { echo "force remove vg cryptdata" - doas dmsetup info --columns + #doas dmsetup info --columns doas dmsetup remove /dev/mapper/cryptdata-* doas dmsetup remove /dev/mapper/cryptdata } @@ -43,12 +43,31 @@ umount_devices() { doas umount -R $Mountpoint_data } +error_umount() { + echo "Error, can't umount all devices, need some manual help." >&2 + lsblk + exit 1 +} + +error_deactivate_vg() { + echo "Error, impossible de deactive vg." >&2 + doas dmsetup info --columns + echo "Try to force remove vgdisk from memory." >&2 + if force_remove_vgdevice + then + echo "could at list remove vgdevice." + exit 0 + else + echo "couldn't remove vgdevice. need manual intervention." >&2 + exit 1 + fi + +} umount_lvm_on_luks() { echo "locking device cryptdata" - umount_devices || echo "Error; can't umount devices" >&2 && exit 0 + umount_devices || error_umount - #doas umount -R /home/primardj || echo "Error, can't umount devices" >&2 && exit 0 doas lvchange -a n cryptdata || force_remove_vgdevice doas cryptsetup close cryptdata }