From c7793b68eafb52fdc423e141ecb6c7bcd76b4eb4 Mon Sep 17 00:00:00 2001 From: DannyDannyDanny Date: Tue, 31 Mar 2026 14:24:58 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20detect=20already-open=20LUKS=20device=20?= =?UTF-8?q?in=20post-install=20provisioning=20=F0=9F=94=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit disko-install leaves the LUKS device open; re-opening failed with "Device crypted already exists". Now detects the open mapper and skips the redundant cryptsetup open call. --- scripts/nixos-server-install.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/nixos-server-install.sh b/scripts/nixos-server-install.sh index f5a67e2..d8370ed 100644 --- a/scripts/nixos-server-install.sh +++ b/scripts/nixos-server-install.sh @@ -135,12 +135,16 @@ if [[ ! -b "$LUKS_DEV" ]]; then exit 0 fi -if ! echo -n "$luks_pass" | cryptsetup open "$LUKS_DEV" crypted --key-file -; then +if [[ -e /dev/mapper/crypted ]]; then + echo " [ok] LUKS device already open (left open by disko-install)" + unset luks_pass +elif ! echo -n "$luks_pass" | cryptsetup open "$LUKS_DEV" crypted --key-file -; then echo "Wrong LUKS passphrase. Complete provisioning manually after boot." unset luks_pass exit 0 +else + unset luks_pass fi -unset luks_pass mount /dev/mapper/crypted /mnt [[ -b "$ESP_DEV" ]] && mount "$ESP_DEV" /mnt/boot