In the bug report 905683 there was a proposed workaround and patch that should solve this problem. But even with the patch, the password dialogue still appeared for me. Tracking down the problem I found out that actually all this is working fine. However there are incompatibilities between the old non-systemd way of booting and new with systemd used. Thus switching to systemd requires some changes and I hope this post will help.
I. The incompatibilities
a) rd.luks.key
- non-systemd format is:
rd.luks.key=<keypath>:<keydev>:<luksdev>
Note the <keypath> is relative to the <keydev> mounting point.
- for systemd it is “the password file”
In here the key path is the 'full' path, so not relative to the key device mount point.
b) crypttab file handling (if not explicitely blocked by 'rd.luks.crypttab=0')
If command line 'rd.luks.uuid=' entry is found also in crypttab the latter is preferred, with following exceptions:
- non-systemd
If the crypttab 3rd entry (password/file) is 'none', the command line 'rd.luks.key=' will be used instead.
- systemd
If the crypttab 3rd entry (password/file) is 'none', the command line 'rd.luks.key=' will NOT be used instead.
c) rd.luks.key.tout
- non-systemd
It specifies the timeout for mounting the key storage device, when it passes and the device is not found the password dialogue appears.
- systemd
This parameter is not available directly in systemd. It means that having a key file on external device that is not mounted quickly enough the key file will not be used.
e) rd.luks.uuid
- non-systemd
The shortest but unique beginning of UUID is acceptable.
- systemd
The full long UUID number must be specified.
(bugzilla 980764)
II. How to switch to systemd?
a) use full path, and ONLY the path (so remove any ':<>:<>' after it), in 'rd.luks.key='
b) ensure valid full key path is in crypttab (not 'none' nor '-') or do not use crypttab by
setting 'rd.luks.crypttab=0'.
Note: the crypttab file that goes into initramfs is not the same as /etc/crypttab found in the system. It is based on it but entries are filtered out by dracut during the image creation. The logic adds only system directories, the '/home' is omitted. Thus if there is a need of having '/home' in crypttab, its mount point must be specified in fstab and the fstab must be explicitly added during dracut image creation with '--add-fstab=' option.
c) create systemd mount unit file for the key device or alternatively add such entry into fstab, with the 'x-systemd.device-timeout=' option in it. This will work as 'rd.luks.key.tout' for old way. If using fstab way the appropriate fstab file must be included during dracut image creation as mentioned above ('--add-fstab=' option).
Example:
Assume there are following standard partitons:
- swap luks with UUID=_swap_luks_uuid_
- /home luks with UUID=_home_luks_uuid_
- key device with UUID=_key_dev_uuid_ with the key.file in its root directory, vfat formatted
1) old non-systemd way
- block systemd during dracut image generation and add vfat module for key device by adding this into /etc/dracut.conf.d/luks-workaround.conf:
Code:
omit_dracutmodules+=" systemd "
add_drivers+=" vfat"
- fstab
Code:
/dev/mapper/luks-_home_luks_uuid_ /home <rest of the options>
/dev/mapper/luks-_swap_luks_uuid_ swap <rest of the options>
-crypttab (unless not using it)
Code:
luks-_home_luks_uuid_ UUID=_home_luks_uuid_ none <rest of the options>
luks-_swap_luks_uuid_ UUID=_swap_luks_uuid_ none <rest of the options>
- command line
Code:
rd.luks.uuid=luks-_just_beginning_of_home_luks_uuid_ rd.luks.uuid=luks-_just_beginning_swap_luks_uuid_ rd.luks.key=key.file:UUID=_key_dev_uuid_ rd.luks.key.tout=5
-regenerate initramfs/grub.conf:
Code:
grub2-mkconfig -o /boot/grub2/grub.cfg
dracut -f /boot/initramfs-`uname -r`.img
2) new systemd way
- add fstab for key device mount and timeout (and to get /home in generated crypttab if needed) and add vfat module for key device during dracut image generation by adding this into /etc/dracut.conf.d/luks-workaround.conf:
Code:
add_fstab+=" /etc/fstab"
add_drivers+=" vfat"
- fstab (assume the key device will be mounted on /mnt/keydev)
Code:
/dev/mapper/luks-_home_luks_uuid_ /home <rest of the options>
/dev/mapper/luks-_swap_luks_uuid_ swap <rest of the options>
UUID=_key_dev_uuid_ /mnt/keydev vfat defaults,ro,umask=0277,x-systemd.device-timeout=5 0 0
-crypttab (unless not using it)
Code:
luks-_home_luks_uuid_ UUID=_home_luks_uuid_ /mnt/keydev/key.file <rest of the options>
luks-_swap_luks_uuid_ UUID=_swap_luks_uuid_ /mnt/keydev/key.file <rest of the options>
- command line (the 'rd.' might be omitted)
Taking everything from command line, ignoring crypttab:
Code:
rd.luks.crypttab=0 rd.luks.uuid=luks-_home_luks_uuid_ rd.luks.uuid=luks-_swap_luks_uuid_ rd.luks.key=/mnt/keydev/key.file
Alternatively nothing might be added to the command line providing everything is in crypttab. However, if any default initramfs is used it won't boot then, so having UUIDs in command line might be helpful.
- regenerate initramfs/grub.conf:
Code:
grub2-mkconfig -o /boot/grub2/grub.cfg
dracut -f /boot/initramfs-`uname -r`.img
Note: as the command line key works thanks to the systemd patch, the timeout when the key device is not present is not working. It is possible to switch to the password adding 'nofail' to the fstab for key device, so:
Code:
UUID=_key_dev_uuid_ /mnt/keydev vfat defaults,ro,umask=0277,x-systemd.device-timeout=5,nofail 0 0
and deactivate the the key file in command line:
Code:
rd.luks.crypttab=0 rd.luks.uuid=luks-_home_luks_uuid_ rd.luks.uuid=luks-_swap_luks_uuid_ rd.luks.key=none