Hello, I am trying to setup udev to automatically open a LUKS partition of my external USB drive once it is plugged in. I have written the following udev rules script: ACTION="add", ENV{DEVTYPE}="partition", ENV{ID_SERIAL}="<serial number of the drive>", RUN+="/usr/sbin/cryptsetup --key-file /etc/keyfile luksOpen /dev/%k usbhd" ACTION="remove", ENV{DEVTYPE}="partition", ENV{ID_SERIAL}="<serial number of the drive>", RUN+="/usr/sbin/cryptsetup luksClose usbhd" Udev seems to recognize my drive but instead of creating /dev/mapper/usbhd I get some nonsense like /dev/mapper/temporary-cryptsetup-7501 or similar. I don't know what this is but it seems not to work when I try to mount it. Any ideas? -- Henri Häkkinen
Henri Häkkinen schrieb:
ACTION="add", ENV{DEVTYPE}="partition", ENV{ID_SERIAL}="<serial number of the drive>", RUN+="/usr/sbin/cryptsetup --key-file /etc/keyfile luksOpen /dev/%k usbhd" ACTION="remove", ENV{DEVTYPE}="partition", ENV{ID_SERIAL}="<serial number of the drive>", RUN+="/usr/sbin/cryptsetup luksClose usbhd"
Udev seems to recognize my drive but instead of creating /dev/mapper/usbhd I get some nonsense like /dev/mapper/temporary-cryptsetup-7501 or similar. I don't know what this is but it seems not to work when I try to mount it. Any ideas?
cryptsetup creates this device to be able to access the key storage, then extracts the key and closes it again (you should not try to access this temporary-cryptsetup-XXXX device, as writing to it might destroy your LUKS header). This means that cryptsetup hangs in the middle of the process here. I am not entirely sure what the problem is, only that I wouldn't perform such an operation inside a udev rule, as udev opens the device several times to get labels, UUIDs and so on. Isn't it possible for you to use pmount to mount the device (pmount can open LUKS automatically)?
2009/3/7 Thomas Bächler <thomas@archlinux.org>:
Henri Häkkinen schrieb:
[ udev rule to run cryptsetup on plugging in ]
Udev seems to recognize my drive but instead of creating /dev/mapper/usbhd I get some nonsense like /dev/mapper/temporary-cryptsetup-7501 or similar.
[...] cryptsetup creates this device to be able to access the key storage, then extracts the key and closes it again (you should not try to access this temporary-cryptsetup-XXXX device, as writing to it might destroy your LUKS header). This means that cryptsetup hangs in the middle of the process here.
Hmm, maybe you're trying to acces the HDD too soon? USB-HDD's generally take some time to initialize, so it might just be a timing issue. mvg, Guus
participants (3)
-
Guus Snijders
-
Henri Häkkinen
-
Thomas Bächler