I have an Ubuntu installation here that fails to close a LUKS device after unmount.
kernel: 5.3.0-42-generic
cryptsetup: 2.2.0
root@pc:~# cryptsetup --debug close sdbackup
# cryptsetup 2.2.0 processing "cryptsetup --debug close sdbackup"
# Running command close.
# Locking memory.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
# Allocating crypt device context by device sdbackup.
# Initialising device-mapper backend library.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.40.0.
# Detected dm-crypt version 1.19.0.
# Device-mapper backend running with UDEV support enabled.
# dm status sdbackup [ opencount noflush ] [16384] (*1)
# Releasing device-mapper backend.
# Allocating context for crypt device (none).
# Initialising device-mapper backend library.
Underlying device for crypt device sdbackup disappeared.
# Deactivating volume sdbackup.
# dm versions [ opencount flush ] [16384] (*1)
# dm status sdbackup [ opencount noflush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# dm table sdbackup [ opencount flush securedata ] [16384] (*1)
Device sdbackup is still in use.
# Releasing crypt device (null) context.
# Releasing device-mapper backend.
# Unlocking memory.
Command failed with code -5 (device already exists or device is busy)
Googling around produced the following solutions, but all of them fail
Deleting the partition manually from the kernel map (not working, device busy)
kpartx -d /dev/mapper/sdbackup
partprobe
dmsetup, lsof, kill
dmsetup ls
nvme0n1p3_crypt (253:0)
sdbackup (253:2)
another_disk (253:1)
sudo lsof |grep 253,2 # produces no results, so nothing to kill
umount -f
The mount output does not contain the partition anymore...
How can I safely remove the encrypted device?