
나는 팔로우했다이 단계Lubuntu 13.10에 암호화된 USB 하드 디스크를 설정하려면이것들암호 대신 키 파일을 사용하여 잠금을 해제합니다. 이제 원시 암호화 장치인 디스크 /dev/disk/by-uuid/32f692ec-e22c-49d3-b6cf-f90e605a5b48, 일반 텍스트 디스크인 /dev/backup/backup 및 파일 시스템이 있는 /mnt/backup이 있습니다. 탑재되어 있습니다. 디스크는 USB3 어댑터로 연결된 일반 SATA 하드 디스크입니다.
디스크를 사용하거나 마운트하는 데 아무런 문제가 없습니다. 문제는 부팅 시 자동으로 마운트하려고 할 때 발생합니다. 기사에서 알 수 있듯이 fstab 및 crypttab에 추가했습니다.
$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/sda2_crypt / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=8afa992c-9174-4a70-b9a0-1ac25b42dbaf /boot ext2 defaults 0 2
/dev/mapper/sdb2_crypt /home ext4 defaults 0 2
/dev/mapper/sdb1_crypt /var ext4 defaults 0 2
/dev/backup/backup /mnt/backup ext4 defaults 0 3
$ cat /etc/crypttab
sda2_crypt UUID=6450d0e6-539b-4fa0-a9e1-f06edfbb5ba9 none luks
sdb1_crypt UUID=f30e6efe-8e58-42b6-aed0-dc7999510744 /root/keyfile luks
sdb2_crypt UUID=17f1f107-8f05-4dbd-8172-4d595411d874 /root/keyfile luks
backup UUID=32f692ec-e22c-49d3-b6cf-f90e605a5b48 /root/keyfile luks
(어쩌면 "backup"이 /etc/crypttab에 있는 올바른 이름이 아닐 수도 있습니다. 저는 /dev/sda2_crypt가 없습니다.)
이로 인해 부팅 시 "/mnt/backup용 디스크가 준비되지 않았거나 존재하지 않습니다"라는 메시지가 표시되면서 중단됩니다.
그때까지는 디스크가 준비되지 않았을 수도 있다고 생각하여 대신 /etc/rc.local에 마운트해 보았습니다.
$ cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
logger Mounting backup disk...
ls -l /dev/disk/by-uuid/ > /home/rena/disk-uuid.txt
stat /root/keyfile >> /home/rena/disk-uuid.txt
whoami >> /home/rena/disk-uuid.txt
cryptsetup --verbose --key-file=/root/keyfile luksOpen /dev/disk/by-uuid/32f692ec-e22c-49d3-b6cf-f90e605a5b48 backup
logger Unlocked OK.
mount /dev/backup/backup /mnt/backup/
logger Mounted OK.
exit 0
syslog 출력에서 잠금이 해제되었지만 마운트되지는 않았음을 알 수 있습니다. 해당 줄에 도달하면 전체 rc.local 스크립트가 방금 종료된 것 같습니다. 또한 ls, stat 및 whoami를 통해 디스크가 실제로 목록에 있고 키 파일에 액세스할 수 있으며 스크립트가 루트로 실행되고 있음을 확인할 수 있습니다. 그래서 왜 마운트가 실패하는지 모르겠습니다.
가장 이상한 부분은 rc,local에서 이 모든 것을 제거하고 부팅 후 터미널에 명령을 입력하는 것입니다.
sudo cryptsetup --verbose --key-file=/root/keyfile luksOpen /dev/disk/by-uuid/32f692ec-e22c-49d3-b6cf-f90e605a5b48 backup
sudo mount /dev/backup/backup /mnt/backup/
잘 장착됩니다. 그렇다면 rc.local과 fstab/crypttab에서 왜 실패합니까?