improve umount mecanism

This commit is contained in:
primardj 2024-01-23 17:28:42 +00:00
parent e9bc79f735
commit b780ac75ae

25
dmount
View file

@ -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
}