无法在 Ubuntu 19.10 上关闭 luks 分区(不涉及 LVM)

无法在 Ubuntu 19.10 上关闭 luks 分区(不涉及 LVM)

我这里有一个 Ubuntu 安装,卸载后无法关闭 LUKS 设备。

核心:5.3.0-42-通用
密码设置: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)

通过谷歌搜索找到了以下解决方案,但都失败了

从内核映射中手动删除分区(不起作用,设备繁忙)

kpartx -d /dev/mapper/sdbackup
partprobe

dmsetup,lsof,杀死

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

卸载 -f

安装输出不再包含分区......

我如何才能安全地删除加密设备?

答案1

我无法添加评论,因为我刚刚创建了这个帐户来评论这篇文章,所以我将以答案的形式发布。功劳应该归于ʇsәɹoɈ,他的第一条评论应该被标记为答案而不是评论。对我来说,这真是太神奇了。

我遇到了与 OP 相同的问题,尝试了所有方法,但没有任何记录表明仍在使用该挂载。实际发生的是,我仍然有一个正在运行的 docker 容器,并且绑定到挂载(即在它自己的命名空间中)。

关闭容器,luksClose 运行没有任何问题!

相关内容