#/bin/bash MOUNTPOINT_cours=/home/primardj/cours MOUNTPOINT_doc=/home/primardj/Documents MOUNTPOINT_virt_machine=/home/primardj/virtual_machine MOUNTPOINT_data=/home/primardj/data remove_vgdevices() { echo "force remove devices." >&2 doas dmsetup info --columns echo "removing all cryptdata volumes" >&2 sleep 3 array=(/dev/mapper/cryptdata-*) for i in ${array[@]}; do echo "$i" doas dmsetup remove "$i" done doas dmsetup remove cryptdata } echo locking device cryptdata doas umount -R $MOUNTPOINT_cours doas umount -R $MOUNTPOINT_doc doas umount -R $MOUNTPOINT_virt_machine doas umount -R $MOUNTPOINT_data doas lvchange -a n cryptdata || remove_vgdevices doas cryptsetup close cryptdata