2010-10-25 02:57:30 +02:00
|
|
|
{pkgs, config, ...}:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
luksRoot = config.boot.initrd.luksRoot;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
boot.initrd.luksRoot = mkOption {
|
2010-10-26 00:21:51 +02:00
|
|
|
default = "";
|
2010-10-25 02:57:30 +02:00
|
|
|
example = "/dev/sda3";
|
|
|
|
description = '';
|
|
|
|
The device that should be decrypted using LUKS before trying to mount the
|
|
|
|
root partition. This works for both LVM-over-LUKS and LUKS-over-LVM setups.
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-10-25 02:57:30 +02:00
|
|
|
Make sure that initrd has the crypto modules needed for decryption.
|
|
|
|
|
|
|
|
The decrypted device name is /dev/mapper/luksroot.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-26 00:21:51 +02:00
|
|
|
config = mkIf (luksRoot != "") {
|
2010-10-25 02:57:30 +02:00
|
|
|
|
|
|
|
boot.initrd.extraUtilsCommands = ''
|
|
|
|
cp -r ${pkgs.cryptsetup}/lib/* $out/lib/
|
|
|
|
cp -r ${pkgs.popt}/lib/* $out/lib
|
|
|
|
cp ${pkgs.cryptsetup}/sbin/* $out/bin
|
|
|
|
'';
|
|
|
|
|
|
|
|
boot.initrd.postDeviceCommands = ''
|
|
|
|
cryptsetup luksOpen ${luksRoot} luksroot
|
|
|
|
lvm vgscan
|
|
|
|
lvm vgchange -ay
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2011-09-14 20:20:50 +02:00
|
|
|
}
|