Skip to content

Commit 5c5d68d

Browse files
committed
zfsbootmenu-core: try to kexec load twice
On some Lenovo x13s models, kexec load fails the first time. A subsequent attempt is successful.
1 parent 422010f commit 5c5d68d

1 file changed

Lines changed: 24 additions & 13 deletions

File tree

zfsbootmenu/lib/zfsbootmenu-core.sh

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ mount_zfs() {
351351

352352
kexec_kernel() {
353353
local selected fs kernel initramfs output hook_envs
354-
local dtb_prop dtb_try dtb_file kver
354+
local dtb_prop dtb_try dtb_file kver try load_success
355355

356356
selected="${1}"
357357
if [ -z "${selected}" ]; then
@@ -420,11 +420,22 @@ kexec_kernel() {
420420
zdebug "no devicetree property set"
421421
fi
422422

423-
if ! output="$( kexec -a -l "${mnt}${kernel}" \
424-
--initrd="${mnt}${initramfs}" \
425-
${dtb_file:+--dtb="${dtb_file}"} \
426-
--command-line="${root_prefix}${fs} ${cli_args}" 2>&1 )"
427-
then
423+
load_success=
424+
425+
# shellcheck disable=SC2034
426+
for try in 1 2 ; do
427+
if output="$( kexec -a -l "${mnt}${kernel}" \
428+
--initrd="${mnt}${initramfs}" \
429+
${dtb_file:+--dtb="${dtb_file}"} \
430+
--command-line="${root_prefix}${fs} \
431+
${cli_args}" 2>&1 )"
432+
then
433+
load_success=1
434+
break
435+
fi
436+
done
437+
438+
if [ -z "${load_success}" ]; then
428439
zerror "unable to load ${mnt}${kernel} and ${mnt}${initramfs} into memory"
429440
zerror "${output}"
430441
recursive_umount "${mnt}"
@@ -456,13 +467,13 @@ kexec_kernel() {
456467

457468
echo -e "\nBooting $( colorize yellow "${kernel}" ) for $( colorize cyan "${fs}" ) ...\n"
458469

459-
if ! output="$( kexec -e -i 2>&1 )"; then
460-
zerror "kexec -e -i failed!"
461-
zerror "${output}"
462-
timed_prompt -d 10 \
463-
-m "$( colorize red "kexec run of ${kernel} failed!" )"
464-
return 1
465-
fi
470+
output="$( kexec -e -i 2>&1 )"
471+
472+
# If we ever reach this, it means our kexec failed
473+
zerror "kexec -e -i failed!"
474+
zerror "${output}"
475+
timed_prompt -d 10 -m "$( colorize red "kexec run of ${kernel} failed!" )"
476+
return 1
466477
}
467478

468479
# arg1: snapshot name

0 commit comments

Comments
 (0)