Debian – Is it possible to unlock multiple LUKS devices to form a LVM at boot

debianlinuxlukslvm

I have the following setup: A LUKS encrypted SSD on which a LVM is used to form the typical linux partitions (/, /home/, etc.). This setup is unlocked at boot by a password. I'm using Debian Jessie.

Due to the lack of space, I wanted to add another PV to the LVM, which of course should be LUKS encrypted and decrypted at boot – with the use of key derivation from the first PV or by using the same password as the first PV.

This means that the LVM (which includes /, /home/, etc.) spans over two LUKS encrypted SSDs (of course each SSD contains one partition that is actually encrypted and not the SSDs themselves, but I think this is obvious.).

It seems impossible to unlock this kind of setup at boot since Systemd has been integrated – all found instructions derive keys (or else) that is not possible to do anymore with Systemd beacause the key derivation scripts are not executed anymore at boot (or the instructions just fail).

Does someone know if and how this actually works?

Otherwise I have to change my setup to have a seperate root partition (outside the LVM) so that the rest can be mounted after boot, or to have luks inside the lvm. But both are the last options I want to choose.

Thx!

Best Answer

Method 1 I found, since Systemd was implemented in *buntu desktop, that it will unlock all additional LUKS partitions if

  1. all of the partitions you want to unlock use the same password
  2. you enter the password for the root partition correctly the first time. If you get it wrong, you'll need to enter it again for every other LUKS partition

This does not work for me in Ubuntu Server 16.04

Method 2 Using the gnome-disk-utility (GUI) app...

  1. select the encrypted LUKS partition
    1. click the gear button (additional partition options)
    2. Edit encryption options
    3. disable auto encryption options
    4. enable Unlock at startup
    5. (optional) change Name. This will label the unlocked partition under /dev/mapper/
    6. enter passphrase. The utility will create a keyfile in /etc/luks-keys/ for each partition you set up this way
    7. (optional) add unlocked partitions to fstab manually or using the disk utility
    8. update-initramfs (not sure if this is required)
    9. update-grub

Method 3 Using keyutils.

I haven't tested this. From https://www.redpill-linpro.com/techblog/2016/08/12/btrfs-and-encryption.html

  1. make use of the same passphrase for both of the encrypted volumes.
  2. Boot into your newly installed system:
  3. ~# apt-get install keyutils and add the keyscript=decrypt_keyctl option to both of the encrypted volumes listed in /etc/crypttab.
  4. Then issue: ~# update-initramfs -u -k all to update your initramfs to include keyutils.
  5. Then reboot and check that the entered passphrase is cached and used to unlock both of the encrypted volumes.
Related Question