diff --git a/initrd/etc/luks-functions b/initrd/etc/luks-functions index eb2d1fb6..4abcd4f2 100644 --- a/initrd/etc/luks-functions +++ b/initrd/etc/luks-functions @@ -14,7 +14,9 @@ list_local_luks_devices() { if cryptsetup isLuks "$device"; then DEBUG "Device $device is a LUKS device" dev_name=$(basename "$device") - parent_dev_name=$(echo "$dev_name" | sed 's/[0-9]*$//') + # Dynamically determine parent device name + parent_dev_name=$(echo "$dev_name" | sed -E 's/(p?[0-9]+)$//') # Handles both NVMe (pX) and non-NVMe (X) + DEBUG "Derived parent device name: $parent_dev_name" if [ -e "/sys/block/$parent_dev_name" ]; then DEBUG "Device $device exists in /sys/block" if ! stat -c %N "/sys/block/$parent_dev_name" 2>/dev/null | grep -q "usb"; then @@ -50,7 +52,7 @@ prompt_luks_passphrase() { # Test LUKS passphrase against all found LUKS containers that are not USB test_luks_passphrase() { TRACE_FUNC - + DEBUG "Testing LUKS passphrase against all found LUKS containers" list_local_luks_devices >/tmp/luks_devices.txt if [ ! -s /tmp/luks_devices.txt ]; then warn "No LUKS devices found" @@ -59,7 +61,7 @@ test_luks_passphrase() { valid_luks_devices=() while read -r luks_device; do - DEBUG "Testing passphrase on $luks_device" + DEBUG "Testing passphrase on device: $luks_device" if cryptsetup open --test-passphrase "$luks_device" --key-file /tmp/secret/luks_current_Disk_Recovery_Key_passphrase; then DEBUG "Passphrase valid for $luks_device" valid_luks_devices+=("$luks_device") @@ -69,10 +71,11 @@ test_luks_passphrase() { done