이 udev 규칙으로 인해 cryptsetup이 정지되는 이유는 무엇입니까?

이 udev 규칙으로 인해 cryptsetup이 정지되는 이유는 무엇입니까?

시스템에서 드라이브를 꺼낼 때마다 나에게 이메일을 보내는 스크립트를 실행하는 규칙이 있습니다.

SUBSYSTEM=="block", ACTION=="remove", ENV{DEVTYPE}=="disk",\
    RUN="/usr/sbin/disk-monitor.sh $env{DEVNAME}"

스크립트는 다음과 같습니다.

#!/bin/bash

echo "Dropout detected $(date)" | mail -s "WARNING: Drive $1 has dropped out!" logger@gentooserver

이로 인해 "cryptsetup close" 및 "integritysetup format"과 같은 특정 cryptsetup 명령이 정지됩니다. 왜 이런 일이 발생합니까?

cryptsetup --debug close offline1
# cryptsetup 2.4.3 processing "cryptsetup --debug close offline1"
# Running command close.
# Locking memory.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
# Allocating crypt device context by device offline1.
# Initialising device-mapper backend library.
# dm version   [ opencount flush ]   [16384] (*1)
# dm versions   [ opencount flush ]   [16384] (*1)
# Detected dm-ioctl version 4.47.0.
# Detected dm-crypt version 1.24.0.
# Detected dm-integrity version 1.10.0.
# Device-mapper backend running with UDEV support enabled.
# dm status offline1  [ opencount noflush ]   [16384] (*1)
# Releasing device-mapper backend.
# Trying to open and read device /dev/sdk1 with direct-io.
# Allocating context for crypt device /dev/sdk1.
# Trying to open and read device /dev/sdk1 with direct-io.
# Initialising device-mapper backend library.
# dm versions   [ opencount flush ]   [16384] (*1)
# dm table offline1  [ opencount flush securedata ]   [16384] (*1)
# Trying to open and read device /dev/sdk1 with direct-io.
# dm versions   [ opencount flush ]   [16384] (*1)
# dm deps offline1  [ opencount flush ]   [16384] (*1)
# Crypto backend (OpenSSL 1.1.1t  7 Feb 2023) initialized in cryptsetup library version 2.4.3.
# Detected kernel Linux 6.1.12-gentoo-x86_64 x86_64.
# Reloading LUKS2 header (repair disabled).
# Acquiring read lock for device /dev/sdk1.
# Opening lock resource file /run/cryptsetup/L_8:161
# Verifying lock handle for /dev/sdk1.
# Device /dev/sdk1 READ lock taken.
# Trying to read primary LUKS2 header at offset 0x0.
# Opening locked device /dev/sdk1
# Verifying locked device handle (bdev)
# LUKS2 header version 2 of size 16384 bytes, checksum sha256.
# Checksum:a4bc53825c88a45b53709738107a718a9c4f896dfef90951cfd9d9cfe68dd259 (on-disk)
# Checksum:a4bc53825c88a45b53709738107a718a9c4f896dfef90951cfd9d9cfe68dd259 (in-memory)
# Trying to read secondary LUKS2 header at offset 0x4000.
# Reusing open ro fd on device /dev/sdk1
# LUKS2 header version 2 of size 16384 bytes, checksum sha256.
# Checksum:ca42f7c96748267f126f3ab48536dee1a05525aa1db10a1feb85a5a60e3338e8 (on-disk)
# Checksum:ca42f7c96748267f126f3ab48536dee1a05525aa1db10a1feb85a5a60e3338e8 (in-memory)
# Device size 4000785964544, offset 16777216.
# Device /dev/sdk1 READ lock released.
# PBKDF argon2id, time_ms 2000 (iterations 0), max_memory_kb 1048576, parallel_threads 4.
# Deactivating volume offline1.
# dm versions   [ opencount flush ]   [16384] (*1)
# dm status offline1  [ opencount noflush ]   [16384] (*1)
# dm versions   [ opencount flush ]   [16384] (*1)
# dm table offline1  [ opencount flush securedata ]   [16384] (*1)
# Trying to open and read device /dev/sdk1 with direct-io.
# dm versions   [ opencount flush ]   [16384] (*1)
# dm deps offline1  [ opencount flush ]   [16384] (*1)
# dm versions   [ opencount flush ]   [16384] (*1)
# dm table offline1  [ opencount flush securedata ]   [16384] (*1)
# dm versions   [ opencount flush ]   [16384] (*1)
# Udev cookie 0xd4d82bf (semid 5) created
# Udev cookie 0xd4d82bf (semid 5) incremented to 1
# Udev cookie 0xd4d82bf (semid 5) incremented to 2
# Udev cookie 0xd4d82bf (semid 5) assigned to REMOVE task(2) with flags DISABLE_LIBRARY_FALLBACK         (0x20)
# dm remove offline1  [ opencount flush retryremove ]   [16384] (*1)
# Udev cookie 0xd4d82bf (semid 5) decremented to 1
# Udev cookie 0xd4d82bf (semid 5) waiting for zero //hangs here

udev 로그:

Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: Device is queued (SEQNUM=4516, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: Device ready for processing (SEQNUM=4516, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: Successfully forked off 'n/a' as PID 8410.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: Worker [8410] is forked for processing SEQNUM=4516.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: 252:2: Device is queued (SEQNUM=4517, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: 252:2: Device ready for processing (SEQNUM=4517, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Processing device (SEQNUM=4516, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Removing watch handle 50.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: Successfully forked off 'n/a' as PID 8411.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: 252:2: Worker [8411] is forked for processing SEQNUM=4517.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: Device is queued (SEQNUM=4518, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: SEQNUM=4518 blocked by SEQNUM=4516
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: /usr/lib/udev/rules.d/95-dm-notify.rules:12 RUN '/sbin/dmsetup udevcomplete $env{DM_COOKIE}'
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: /usr/lib/udev/rules.d/disk-monitor.rules:4 RUN '/usr/sbin/disk-monitor.sh $env{DEVNAME}'
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: No reference left for '/dev/mapper/offline1', removing
Feb 26 18:51:38 gentoodesktop systemd-udevd[8411]: 252:2: Processing device (SEQNUM=4517, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: No reference left for '/dev/disk/by-id/dm-name-offline1', removing
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: No reference left for '/dev/disk/by-id/dm-uuid-CRYPT-LUKS2-f2eafcc2880e4d34afa3132486d1d6ae-offline1', removing
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: No reference left for '/dev/disk/by-uuid/5d5633e2-2f7c-49de-babf-f3ed263a3c8b', removing
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Running command "/usr/sbin/disk-monitor.sh /dev/dm-2"
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Starting '/usr/sbin/disk-monitor.sh /dev/dm-2'
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: Successfully forked off '(spawn)' as PID 8412.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8411]: 252:2: Device processed (SEQNUM=4517, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8411]: 252:2: sd-device-monitor(worker): Passed 167 byte to netlink monitor.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Process '/usr/sbin/disk-monitor.sh /dev/dm-2' succeeded.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Device processed (SEQNUM=4516, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: sd-device-monitor(worker): Passed 963 byte to netlink monitor.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: Device ready for processing (SEQNUM=4518, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: sd-device-monitor(manager): Passed 230 byte to netlink monitor.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Processing device (SEQNUM=4518, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Removing watch handle -1.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: /usr/lib/udev/rules.d/disk-monitor.rules:4 RUN '/usr/sbin/disk-monitor.sh $env{DEVNAME}'
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Running command "/usr/sbin/disk-monitor.sh /dev/dm-2"
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Starting '/usr/sbin/disk-monitor.sh /dev/dm-2'
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: Successfully forked off '(spawn)' as PID 8419.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Process '/usr/sbin/disk-monitor.sh /dev/dm-2' succeeded.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Device processed (SEQNUM=4518, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: sd-device-monitor(worker): Passed 230 byte to netlink monitor.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: No events are queued, removing /run/udev/queue.
Feb 26 18:51:42 gentoodesktop systemd-udevd[7823]: Cleanup idle workers
Feb 26 18:51:42 gentoodesktop systemd-udevd[8411]: Unload kernel module index.
Feb 26 18:51:42 gentoodesktop systemd-udevd[8410]: Unload kernel module index.
Feb 26 18:51:42 gentoodesktop systemd-udevd[8410]: Unloaded link configuration context.
Feb 26 18:51:42 gentoodesktop systemd-udevd[8411]: Unloaded link configuration context.
Feb 26 18:51:42 gentoodesktop systemd-udevd[7823]: Worker [8411] exited.
Feb 26 18:51:42 gentoodesktop systemd-udevd[7823]: Worker [8410] exited.
Feb 26 18:51:46 gentoodesktop systemd-udevd[7823]: Cleanup idle workers

답변1

여기서 문제는 귀하의 RUN=script지시문이 dmcrypt가 제대로 작동하는 데 필요한 기존 지시문을 덮어쓴다는 것입니다. 더 잘 작동 하는지 확인하기 위해 사용해 보십시오 RUN+="/usr/sbin/disk-monitor.sh $env{DEVNAME}"(참고 +).

이것이 실제로 DEVNAME사실입니까? 블록 장치가 가질 수 있는 속성 에 대해 알려주지 만 이에 대해서는 man udev알려주지 않습니다 .$dev$devpath$devnodeDEVNAME

관련 정보