Haven’t done anything lately. My opinion? Volker should have this taken into core omv, maybe not my plugin necessarily Luks is standard disk encryption for Linux in kernel and very well supported by systemd.
Indeed, that sounds like the better approach. In the meantime, I've done a bit more research and stumbled upon a wonderful approach: udev rules. I just copy the following to /etc/udev/rules.d/15_unlock_luks_with_file and it all works:
Code
KERNEL!="sd[a-z]*", GOTO="end"
ACTION=="add", PROGRAM!="/sbin/blkid -p %N", GOTO="end"
#
# Open luks partition if necessary
PROGRAM=="/sbin/blkid -o value -p -s TYPE %N", RESULT=="crypto_LUKS", ENV{crypto}="mapper/", ENV{device}="/dev/mapper/%k"
ENV{crypto}!="?*", ENV{device}="%N"
ACTION=="add", ENV{crypto}=="?*", RUN+="/sbin/cryptsetup luksOpen --key-file=/root/boring.log %N %k"
ACTION=="add", ENV{crypto}=="?*", TEST!="/dev/mapper/%k", GOTO="end"
ACTION=="remove", ENV{crypto}=="?*", RUN+="/sbin/cryptsetup luksClose %k"
LABEL="end"
The LUKS key is stored in /root/boring.log for obfuscation.