어떤 이유로 cryptsetup 장치 중 하나를 마운트하려고 할 때 systemd가 시간 초과되었습니다. 단위와 스크립트는 다음과 같습니다.
udev 규칙:
ACTION=="add", KERNEL=="sd[a-z][0-9]", ATTRS{serial}=="NA8F9WKF", SYMLINK+="BigHDD", TAG+="systemd"
ACTION=="add", KERNEL=="sd[a-z][0-9]", ATTRS{serial}=="AA00000000065396", SYMLINK+="clavem", TAG+="systemd"
ACTION=="add", KERNEL=="sd[a-z][0-9]", ATTRS{wwid}=="t10.ATA WDC WD10EZRZ-00Z5HB0 WD-WCC4M6HRPV4V", SYMLINK+="HDDsB", TAG+="systemd"
ACTION=="add", KERNEL=="sd[a-z][0-9]", ATTRS{wwid}=="t10.ATA WDC WD10EZRZ-00Z5HB0 WD-WCC4M3EYESNV", SYMLINK+="HDDsC", TAG+="systemd"
mnt-HDD.automount
[Unit]
Description=Automount HDDs
Requires=dev-clavem.device
[Automount]
Where=/mnt/HDDs
[Install]
WantedBy=multi-user.target
mnt-HDD.마운트:
[Unit]
BindsTo=HDDs-unlock.service dev-clavem.device media-clavem.mount
After=HDDs-unlock.service dev-HDDsB.device dev-HDDsC.device
[Mount]
What=/dev/mapper/cryptHDDC
Where=/mnt/HDDs
Type=btrfs
Options= noatime,compress=lzo,autodefrag
HDD 잠금 해제.서비스:
[Unit]
Description=HDDs unlock
BindsTo=mnt-HDDs.mount dev-clavem.device dev-HDDsB.device dev-HDDsC.device
Requires=media-clavem.mount dev-HDDsB.device dev-HDDsC.device
After=media-clavem.mount dev-HDDsB.device dev-HDDsC.device
[Service]
Type=oneshot
RemainAfterExit=yes
KillMode=none
ExecStart=/home/rbenedetti/teste.sh
ExecStop=/sbin/cryptsetup luksClose cryptHDDB ; /sbin/cryptsetup luksClose
cryptHDDC
[Install]
RequiredBy=mnt-HDDs.mount
테스트 파일
#!/bin/bash
i=0
while [[ ! -b /dev/disk/by-uuid/42e7eacf-5e09-4476-8dbc-1919675c1595 ]]; do
echo "cant find /dev/disk/by-uuid/42e7eacf-5e09-4476-8dbc-1919675c1595... waiting. $i" > ~/testLog
if [[ "$counter" -gt 10 ]]; then
echo "giving up." > ~/testLog
exit 1
fi
sleep 0.5
let i++
done
i=0
while [[ ! -b /dev/disk/by-uuid/826b9963-eb49-4eac-a9c0-e741552491d4 ]]; do
echo "cant find /dev/disk/by-uuid/826b9963-eb49-4eac-a9c0-e741552491d4... waiting. $i" > ~/testLog
if [[ "$counter" -gt 10 ]]; then
echo "giving up." > ~/testLog
exit 1
fi
sleep 0.5
let i++
done
/sbin/cryptsetup --key-file /media/clavem/k luksOpen /dev/disk/by-uuid/42e7eacf-5e09-4476-8dbc-1919675c1595 cryptHDDC
/sbin/cryptsetup --key-file /media/clavem/k luksOpen /dev/disk/by-uuid/826b9963-eb49-4eac-a9c0-e741552491d4 cryptHDDB
i=0
while [[ ! -b /dev/mapper/cryptHDDB ]]; do
echo "cant find /dev/mapper/cryptHDDB... waiting. $i" > ~/testLog
/sbin/cryptsetup --key-file /media/clavem/k luksOpen /dev/disk/by-uuid/826b9963-eb49-4eac-a9c0-e741552491d4 cryptHDDB
if [[ "$counter" -gt 10 ]]; then
echo "giving up." > ~/testLog
exit 1
fi
sleep 0.5
let i++
done
i=0
while [[ ! -b /dev/mapper/cryptHDDC ]]; do
echo "cant find /dev/mapper/cryptHDDC... waiting. $i" > ~/testLog
/sbin/cryptsetup --key-file /media/clavem/k luksOpen /dev/disk/by-uuid/42e7eacf-5e09-4476-8dbc-1919675c1595 cryptHDDC
if [[ "$counter" -gt 10 ]]; then
echo "giving up." > ~/testLog
exit 1
fi
sleep 0.5
let i++
done
echo "somehow passed...>" > ~/testLog
teste.sh는 주로 일회성 서비스에서 시간 초과가 발생하는 이유를 알아내기 위한 테스트입니다. 실행하는 동안 어떤 이유로 systemctl restart mnt-HDDs.mount
모든 것이 잘 되고 내 파티션이 마운트됩니다... 시간 초과가 발생합니다.mnt-mapper-cryptHDDC.device
답변1
글쎄, 분명히 cryptHDDB
설치 작업을 통해 udev와 Systemd 사이에 문제가 있다고 믿게 되었습니다.