From 8ab4cbdac337525c76d00fb14ffc30b1f9fbb79b Mon Sep 17 00:00:00 2001 From: Edward Tjörnhammar Date: Mon, 3 Sep 2018 19:45:54 +0200 Subject: nixos: initrd/luks: make uuid specified devices discoverable --- nixos/modules/system/boot/luksroot.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'nixos/modules/system/boot/luksroot.nix') diff --git a/nixos/modules/system/boot/luksroot.nix b/nixos/modules/system/boot/luksroot.nix index ed8b9f01e27..1079089bc5a 100644 --- a/nixos/modules/system/boot/luksroot.nix +++ b/nixos/modules/system/boot/luksroot.nix @@ -11,19 +11,30 @@ let exit 1 } + dev_exist() { + local target="$1" + if [ -e $target ]; then + return 0 + else + local uuid=$(echo -n $target | sed -e 's,UUID=\(.*\),\1,g') + local dev=$(blkid --uuid $uuid) + return $? + fi + } + wait_target() { local name="$1" local target="$2" local secs="''${3:-10}" local desc="''${4:-$name $target to appear}" - if [ ! -e $target ]; then + if ! dev_exist $target; then echo -n "Waiting $secs seconds for $desc..." local success=false; for try in $(seq $secs); do echo -n "." sleep 1 - if [ -e $target ]; then + if dev_exist $target; then success=true break fi -- cgit 1.4.1