当我跑步时:
LANG=C cryptsetup --debug luksClose /dev/mapper/Pool-A
it fails as follows:
device-mapper: remove ioctl on Pool-A failed: Device or resource busy
Device /dev/mapper/Pool-A is still in use.
Command failed with code 16: Device or resource busy(...)(它重复了许多类似的行)
# cryptsetup 1.7.2 processing "cryptsetup --debug luksClose /dev/mapper/Pool-A"
# Running command close.
# Locking memory.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
# Allocating crypt device context by device /dev/mapper/Pool-A.
# Initialising device-mapper backend library.
# dm version OF [16384] (*1)
# dm versions OF [16384] (*1)
# Detected dm-crypt version 1.14.1, dm-ioctl version 4.33.0.
# Device-mapper backend running with UDEV support enabled.
# dm status Pool-A OF [16384] (*1)
# Releasing device-mapper backend.
# Trying to open and read device /dev/sdb1 with direct-io.
# Allocating crypt device /dev/sdb1 context.
# Trying to open and read device /dev/sdb1 with direct-io.
# Initialising device-mapper backend library.
# dm table Pool-A OFW [16384] (*1)
# Trying to open and read device /dev/sdb1 with direct-io.
# Crypto backend (gcrypt 1.5.3) initialized in cryptsetup library version 1.7.2.
# Detected kernel Linux 3.10.0-327.36.3.el7.x86_64 x86_64.
# Reading LUKS header of size 1024 from device /dev/sdb1
# Key length 32, device size 3906961375 sectors, header size 2050 sectors.
# Deactivating volume /dev/mapper/Pool-A.
# dm status Pool-A OF [16384] (*1)
# Udev cookie 0xd4d14d3 (semid 917504) created
# Udev cookie 0xd4d14d3 (semid 917504) incremented to 1
# Udev cookie 0xd4d14d3 (semid 917504) incremented to 2
# Udev cookie 0xd4d14d3 (semid 917504) assigned to REMOVE task(2) with flags (0x0)
# dm remove Pool-A OFT [16384] (*1)(...)(重复25行)
# Releasing crypt device /dev/sdb1 context.
# Releasing device-mapper backend.
# Unlocking memory.
I've found that this problem arises when I tri to use udev rules like that:
ACTION=="add",ENV{ID_SERIAL_SHORT}=="57584E314135364632334141", RUN+="/etc/bacula/openmount.sh A"
ACTION=="remove",ENV{ID_SERIAL_SHORT}=="57584E314135364632334141", RUN+="/etc/bacula/umountclose.sh A"这是低级信息:
[root@backup ~]# dmsetup info Pool-A
Name: Pool-A
State: ACTIVE
Read Ahead: 256
Tables present: LIVE
Open count: 1
Event number: 0
Major, minor: 253, 3
Number of targets: 1
UUID: CRYPT-LUKS1-2b69b6e48b6d4bd1942ae7505d530f27-Pool-A阻止设备信息如下:
lsblk -o +UUID /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT UUID
sdb 8:16 0 1,8T 0 disk
└─sdb1 8:17 0 1,8T 0 part
└─Pool-A 253:3 0 1,8T 0 crypt 48c1accf-47a6-45ec-aacc-6686e8a8a2fa我的操作系统是:
内核为3.10.0-327.36.3.el7.x86_64的CentOS Linux发行版7.2.1511 (Core)
这是一个系统-udev问题吗?我怎么才能修好它?还是说这是个无害的警告?
发布于 2023-04-23 01:18:09
这是系统udev和经典udev的不同之处。systemd安装在单独的命名空间中,因此运行脚本中的挂载不会被用户看到。您可以尝试systemctl restart udev,如果这释放了锁,这就是问题所在。要正确地做到这一点,您必须在systemd中工作。为我工作的是: udev规则来捕获正在插入的USB驱动器:
ACTION=="add", KERNEL=="sd?1", ENV{ID_SERIAL_SHORT}=="575...", SYMLINK+="offsitebackup", TAG+="systemd", ENV{SYSTEMD_WANTS}+="offsite-backup.service"这将创建指向驱动器的第一个分区的/dev/offsitebackup链接,并触发服务。服务文件是:
[Unit]
Description=Offsite Backup script
Requisite=dev-offsitebackup.device
BindsTo=dev-offsitebackup.device
After=dev-offsitebackup.device
[Service]
ExecStart=/usr/local/scripts/offsite-backup.ksh offsitebackup
Type=oneshot
StandardOutput=journal
[Install]
WantedBy=dev-offsitebackup.device然后,脚本执行luksOpen/挂载/copy/umount/luksClose。此外,要测试这些,您可以使用以下方法模拟USB驱动器的拔出/复制:
udevadm trigger -v -c remove /dev/sda
udevadm trigger -v -c add /dev/sda您可以使用以下方法查看系统中的设备/脚本状态:
systemctl status dev-offsitebackup.device
systemctl status offsite-backup.servicehttps://serverfault.com/questions/824425
复制相似问题