You are not logged in.

#1 2013-10-31 08:25:19

beachcoder
Member
Registered: 2009-10-08
Posts: 130

[SOLVED] LUKS-encrypted USB-drive should be unlocked automatically

Hi,

I'm having some trouble with an external USB-hard-drive that I want to be unlocked during boot automatically by a password stored into a file, but it doesn't work. The hard-drive can be mounted without problems manually. My desired behavior is, that the system continues booting if the hard-drive is not present or it unlocks it silently and I'm able to use it, if it is present, so I thought using "nofail" would be the correct option.

/etc/crypttab:

storage UUID=18345ef2-0de9-49cf-81e4-4b73c88ed3a0  /etc/storage.pw nofail,luks

/etc/storage.pw: contains the password, has mode 600, owned by root.

/etc/fstab (partly):

/dev/mapper/storage     /mnt/storage    ext3            defaults,noatime,nofail 0 2

I think the problem is somewhing with my /etc/crypttab configuration. Altrought I specified a path to the password, I see a message for prompting the password during boot, but systemd continues booting and takes me into my X session before I've got the possibilty to enter the password. Why is the password not read?

I've also tried this, but don't understeand the meany why my drive is "dead":

$ systemctl status mnt-storage.mount 
mnt-storage.mount - /mnt/storage
   Loaded: loaded (/etc/fstab)
   Active: inactive (dead)
    Where: /mnt/storage
     What: /dev/mapper/storage

Any ideas?

Last edited by beachcoder (2013-10-31 21:45:07)

Offline

#2 2013-10-31 21:44:30

beachcoder
Member
Registered: 2009-10-08
Posts: 130

Re: [SOLVED] LUKS-encrypted USB-drive should be unlocked automatically

Hey folks, a friend helped me with this issue.

I've created a new, random key, wrote it to a file /etc/storare.key and added it as secondary LUKS key to the device.

$ dd if=/dev/random of=/etc/storage.key bs=64 count=1
$ cryptsetup luksAddKey /dev/sdb1 /etc/storage.key

/etc/crypttab:

storage /dev/disk/by-uuid/18345ef2-0de9-49cf-81e4-4b73c88ed3a0  /etc/storage.key nofail

So I think  the problem was in the keyfile that I created manually as text file. The new key, generated by dd, contains binary data and is taken so.

So long,
beachcoder

Offline

Board footer

Powered by FluxBB