有一个外部设备,用LUKS加密,插入时自动挂载,如果启动时不出现任何问题,则不会引起任何问题。
关于这个主题的大多数问题都是关于在引导上挂载的--这不是我想要做的。
此外,当usb设备不存在时,应保护挂载点不发生意外写入,我可以使用chattr +i
完成此操作。
mount /mnt/backup
或mount /dev/mapper/fit
手动挂载设备,这似乎正确地使用了fstab设置。# /etc/crypttab
fit UUID=xxxxxxxx-xxxxx-xxxxxxxx-xxxxxxxxxx none luks,noauto
# /etc/fstab
/dev/mapper/fit /mnt/backup ext4 noatime,user,noauto,x-systemd.automount,x-systemd.device-timeout=5ms,x-systemd.mount-timeout=100ms 0 0
如果有人想知道我的名字的话,我正好有一个三星适配的usb闪存盘。
当外部设备不存在
# Accessing the mountpoint when the drive is NOT plugged in
andy@pop-os:mnt$ ll
ls: cannot access 'backup': No such device
total 0
d????????? ? ? ? ? ? backup/
andy@pop-os:mnt$ mountpoint /mnt/backup
/mnt/backup is a mountpoint
# journalctl
Jan 21 16:33:34 pop-os systemd[1]: mnt-backup.automount: Got automount request for /mnt/backup, triggered by 5192 (ls)
Jan 21 16:33:34 pop-os systemd[1]: dev-mapper-fit.device: Job dev-mapper-fit.device/start timed out.
Jan 21 16:33:34 pop-os systemd[1]: Timed out waiting for device /dev/mapper/fit.
Jan 21 16:33:34 pop-os systemd[1]: Dependency failed for /mnt/backup.
Jan 21 16:33:34 pop-os systemd[1]: mnt-backup.mount: Job mnt-backup.mount/start failed with result 'dependency'.
Jan 21 16:33:34 pop-os systemd[1]: dev-mapper-fit.device: Job dev-mapper-fit.device/start failed with result 'timeout'.
# Absolute path is required if not using sudo (`user` was set in fstab)
andy@pop-os:mnt$ umount /mnt/backup
andy@pop-os:mnt$ sudo cryptsetup close fit
andy@pop-os:mnt$ sudo eject /dev/sdx
我可以卸载挂载点(即使没有安装任何设备)来暂时修复这个问题,但是它会在系统重新启动或重新挂载设备之后返回。
andy@pop-os:mnt$ sudo umount backup
andy@pop-os:mnt$ ll
total 4.0K
drwxr-xr-x 2 root root 4.0K Jan 19 10:16 backup/
andy@pop-os:mnt$ lsattr
----i---------e------- ./backup
andy@pop-os:~$ mountpoint /mnt/backup
/mnt/backup is not a mountpoint
如果我使用noauto
而不包括x-systemd.automount
,那么我避免了在没有设备存在的情况下目录在引导时是一个挂载点的问题,但是我也没有自动登录--尽管设备仍然解锁。
提示密码,设备解锁。
andy@pop-os:mnt$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sdb crypto_LUKS 2 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
└─fit ext4 1.0 yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
andy@pop-os:mnt$ ll backup/
ls: cannot access 'backup/': No such device
注意,MOUNTPOINTS是空的
# journalctl -f
Jan 21 17:17:26 pop-os kernel: usb 6-2: new SuperSpeed USB device number 2 using xhci_hcd
Jan 21 17:17:26 pop-os kernel: usb 6-2: New USB device found, idVendor=090c, idProduct=1000, bcdDevice=11.00
Jan 21 17:17:26 pop-os kernel: usb 6-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 21 17:17:26 pop-os kernel: usb 6-2: Product: Flash Drive FIT
Jan 21 17:17:26 pop-os kernel: usb 6-2: Manufacturer: Samsung
Jan 21 17:17:26 pop-os kernel: usb 6-2: SerialNumber: 0123456789123
Jan 21 17:17:26 pop-os kernel: usb-storage 6-2:1.0: USB Mass Storage device detected
Jan 21 17:17:26 pop-os kernel: scsi host7: usb-storage 6-2:1.0
Jan 21 17:17:26 pop-os mtp-probe[10452]: checking bus 6, device 2: "/sys/devices/pci0000:00/0000:00:08.1/0000:0b:00.4/usb6/6-2"
Jan 21 17:17:26 pop-os mtp-probe[10452]: bus: 6, device: 2 was not an MTP device
Jan 21 17:17:26 pop-os mtp-probe[10467]: checking bus 6, device 2: "/sys/devices/pci0000:00/0000:00:08.1/0000:0b:00.4/usb6/6-2"
Jan 21 17:17:26 pop-os mtp-probe[10467]: bus: 6, device: 2 was not an MTP device
Jan 21 17:17:29 pop-os kernel: scsi 7:0:0:0: Direct-Access Samsung Flash Drive FIT 1100 PQ: 0 ANSI: 6
Jan 21 17:17:29 pop-os kernel: sd 7:0:0:0: Attached scsi generic sg1 type 0
Jan 21 17:17:29 pop-os kernel: sd 7:0:0:0: [sdb] 501253132 512-byte logical blocks: (257 GB/239 GiB)
Jan 21 17:17:29 pop-os kernel: sd 7:0:0:0: [sdb] Write Protect is off
Jan 21 17:17:29 pop-os kernel: sd 7:0:0:0: [sdb] Mode Sense: 43 00 00 00
Jan 21 17:17:29 pop-os kernel: sd 7:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesnt support DPO or FUA
Jan 21 17:17:29 pop-os kernel: sdb: sdb1
Jan 21 17:17:29 pop-os kernel: sd 7:0:0:0: [sdb] Attached SCSI removable disk
Jan 21 17:17:41 pop-os systemd[1]: Starting Cryptography Setup for fit...
Jan 21 17:17:41 pop-os systemd-cryptsetup[10585]: Volume fit already active.
Jan 21 17:17:41 pop-os systemd[1]: Finished Cryptography Setup for fit.
Jan 21 17:17:41 pop-os systemd[1]: Reached target Block Device Preparation for /dev/mapper/fit.
Jan 21 17:17:41 pop-os gnome-shell[3744]: Unable to mount volume 257 GB Encrypted: Gio.IOErrorEnum: Operation was cancelled
Jan 21 17:17:41 pop-os udisksd[1382]: Unlocked device /dev/sdb1 as /dev/dm-4
请注意,在udisksd报告“解锁设备.”之前,第二行“操作被取消”正在发生。
我尝试过两种不同的设备,一种是全磁盘块加密,另一种是加密分区,这没有什么区别。
有时候过一会儿..。
andy@pop-os:mnt$ mount /mnt/backup
mount: /mnt/backup: /dev/mapper/fit already mounted on /mnt/backup.
..。但通常情况下,这只是按预期安装设备。
x-systemd.device-timeout
设置为比默认的90年代少得多的东西,那么我的系统就会慢慢失去响应,然后崩溃。我想systemd
可能是在等待我输入密码,但是更长的超时时间似乎没有帮助。nofail
而不是noauto
来使用稍微不同的方法,但不幸的是没有回答我的问题systemctl show mnt-backup.mount
获得更多的信息,但这并没有帮助我那么,为什么访问挂载点的访问试图在卸载后访问设备,从而导致?为什么插入设备时它不能正确自动运行?在旧的fstab和新的系统之间,我似乎找不到神奇的变量。
如果我不设置设备超时,那么了解为什么系统崩溃也是有用的吗?
发布于 2023-03-22 11:37:32
只是简单的想法..。
也许使用udev
启动脚本/应用程序,为您的挂载点创建dir,然后执行所有的加密设置。此脚本可以使用来自usb驱动器的密钥。
试着做任何事而不使用fstab。
(对不起,我不能评论你的问题)。
https://unix.stackexchange.com/questions/732616
复制相似问题