From d3867b6d65d4c65fef575489bdbfc55169bdc0c4 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 9 Oct 2025 16:52:06 +0800 Subject: [PATCH] Wait for LUKS configfs API to be ready Resolves: https://issues.redhat.com/browse/RHEL-104940 Conflict: None commit 8e779ea2d805124a2e7067efe3aa7d231c2c5cf3 Author: Coiby Xu Date: Wed Sep 24 10:35:08 2025 +0800 Wait for LUKS configfs API to be ready Partially resolves: https://github.com/rhkdump/kdump-utils/issues/109 On Fedora 42, LUKS-encrypted volumes fail to be unlocked in the crash kernel because somehow the volume keys are yet to be available. Wait for the API to be ready before triggering restoring volume keys so that later the keys will be available for cryptsetup to unlock the volumes. Fixes: 5cbd7ddd ("Support dumping to a LUKS-encrypted target") Signed-off-by: Coiby Xu Signed-off-by: Coiby Xu --- dracut-kexec-crypt-setup.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dracut-kexec-crypt-setup.sh b/dracut-kexec-crypt-setup.sh index 7d79ed5..1a00ce5 100644 --- a/dracut-kexec-crypt-setup.sh +++ b/dracut-kexec-crypt-setup.sh @@ -1,3 +1,21 @@ #!/bin/sh # -echo true > /sys/kernel/config/crash_dm_crypt_keys/restore +LUKS_CONFIGFS_RESTORE=/sys/kernel/config/crash_dm_crypt_keys/restore +RESTORED=1 +MAX_WAIT_TIME=10 +wait_time=0 + +while [ $wait_time -lt $MAX_WAIT_TIME ]; do + [ -e $LUKS_CONFIGFS_RESTORE ] && break + sleep 1 + wait_time=$((wait_time + 1)) +done + +if [ $wait_time -ge $MAX_WAIT_TIME ]; then + echo "$LUKS_CONFIGFS_RESTORE isn't ready after ${MAX_WAIT_TIME}s, something wrong!" + exit 1 +fi + +if ! grep -q "$RESTORED" "$LUKS_CONFIGFS_RESTORE"; then + echo $RESTORED > $LUKS_CONFIGFS_RESTORE +fi