diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index cb3d8d4..b85e2dd 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1146,7 +1146,7 @@ remove_cpu_online_rule() { } kdump_check_crypt_targets() { - local _luks_dev _devuuid _key_desc + local _devuuid _key_desc declare -a _luks_devs mapfile -t _luks_devs < <(get_all_kdump_crypt_dev) @@ -1175,8 +1175,7 @@ kdump_check_crypt_targets() { # shellcheck disable=SC2154 mkdir -p "$hookdir/initqueue/finished" CRYPTSETUP_PATH=$(command -v cryptsetup) - for _luks_dev in "${_luks_devs[@]}"; do - _devuuid=$(maj_min_to_uuid "$_luks_dev") + for _devuuid in "${_luks_devs[@]}"; do _key_desc=$LUKS_KEY_PRFIX$_devuuid cat << EOF >> "${initdir}/etc/udev/rules.d/70-luks-kdump.rules" ENV{ID_FS_UUID}=="$_devuuid", \ diff --git a/kdump-lib.sh b/kdump-lib.sh index 5a5d08c..7c1e3bc 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -1210,7 +1210,12 @@ kdump_get_arch_recommend_size() get_recommend_size "$_sys_mem" "$_ck_cmdline" } -# Print all underlying crypt devices of a block device +maj_min_to_uuid() +{ + lsblk -no uuid,MAJ:MIN | awk -v dev="$1" 'NF==2 && $2 == dev {print $1}' +} + +# Print all underlying crypt devices (UUID) of a block device # print nothing if device is not on top of a crypt device # $1: the block device to be checked in maj:min format get_luks_crypt_dev() @@ -1221,7 +1226,7 @@ get_luks_crypt_dev() _type=$(blkid -u filesystem,crypto -o export -- "/dev/block/$1" | \ sed -n -E "s/^TYPE=(.*)$/\1/p") - [[ $_type == "crypto_LUKS" ]] && echo "$1" + [[ $_type == "crypto_LUKS" ]] && maj_min_to_uuid "$1" for _x in "/sys/dev/block/$1/slaves/"*; do [[ -f $_x/dev ]] || continue @@ -1230,11 +1235,6 @@ get_luks_crypt_dev() done } -maj_min_to_uuid() -{ - lsblk -no uuid,MAJ:MIN | awk -v dev="$1" 'NF==2 && $2 == dev {print $1}' -} - # kdump_get_maj_min # Prints the major and minor of a device node. # Example: diff --git a/kdumpctl b/kdumpctl index 7434d17..4e09c76 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1092,7 +1092,7 @@ _get_luks_key_by_unlock() prepare_luks() { - local _luks_dev _key_id _key_des _luks_unlock_cmd + local _key_id _key_des _luks_unlock_cmd declare -a _luks_devs mapfile -t _luks_devs < <(get_all_kdump_crypt_dev) @@ -1109,8 +1109,7 @@ prepare_luks() # For the case of CPU/memory hotplugging, we can reuse loaded keys [[ $(cat $LUKS_CONFIGFS/reuse) == 1 ]] && return 0 - for _luks_dev in "${_luks_devs[@]}"; do - _devuuid=$(maj_min_to_uuid "$_luks_dev") + for _devuuid in "${_luks_devs[@]}"; do _key_dir=$LUKS_CONFIGFS/$_devuuid _key_des=$LUKS_KEY_PRFIX$_devuuid if _key_id=$(keyctl request logon "$_key_des" 2> /dev/null); then