fix: detect already-open LUKS device in post-install provisioning 🔐

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.
This commit is contained in:
DannyDannyDanny 2026-03-31 14:24:58 +02:00
parent d4dbd73a8c
commit c7793b68ea

View file

@ -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