From 9cd4ce98bfc11292fbebc6b85d14bb386e82c9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Mon, 12 Nov 2018 20:34:19 +0100 Subject: [PATCH] nixos/luksroot: Check whether the device already exists The new reuse behaviour is cool and really useful but it breaks one of my use cases. When using kexec, I have a script which will unlock the disks in my initrd. However, do_open_passphrase will fail if the disk is already unlocked. --- nixos/modules/system/boot/luksroot.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nixos/modules/system/boot/luksroot.nix b/nixos/modules/system/boot/luksroot.nix index 018e7b2e7f8..ff3f2a1398a 100644 --- a/nixos/modules/system/boot/luksroot.nix +++ b/nixos/modules/system/boot/luksroot.nix @@ -118,6 +118,11 @@ let do_open_passphrase() { local passphrase + # Return if already unlocked + if ! cryptsetup status "${name}" > /dev/null; then + return + fi + while true; do echo -n "Passphrase for ${device}: " passphrase=