Create a keyfile to automatically decrypt hard drives:

Premise:

Disc /dev/sdb Ubuntu -> otherwise minor adjustments are necessary

Create Keyfile

sudo su
cd /root
mkdir keyfiles; cd keyfiles
dd if=/dev/urandom of=keyfile bs=256 count=1
cryptsetup luksAddKey /dev/sdb ~/keyfiles/keyfile

Mapper at startup

sudo nano /etc/crypttab

Add the following line

sdb_crypt /dev/sdb /root/keyfiles/keyfile luks

Automount

Get the UUID of the disc

sudo blkid
Add entry to /etc/fstab
/dev/mapper/sdb_crypt /mnt/sdb_crypt ext4 defaults 0 2

Explanation fstab

/mnt/sdb_crypt : It’s the mountpoint. You need to create it.

ext4 : The partitiontype.