Skip to content

Commit 488282d

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 488282d

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

zfsbootmenu/lib/zfsbootmenu-core.sh

Lines changed: 22 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 load_success
355355

356356
selected="${1}"
357357
if [ -z "${selected}" ]; then
@@ -420,11 +420,20 @@ 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+
for try in 1 2 ; do
425+
if output="$( kexec -a -l "${mnt}${kernel}" \
426+
--initrd="${mnt}${initramfs}" \
427+
${dtb_file:+--dtb="${dtb_file}"} \
428+
--command-line="${root_prefix}${fs} \
429+
${cli_args}" 2>&1 )"
430+
then
431+
load_success=1
432+
break
433+
fi
434+
done
435+
436+
if [ -z "${load_success}" ]; then
428437
zerror "unable to load ${mnt}${kernel} and ${mnt}${initramfs} into memory"
429438
zerror "${output}"
430439
recursive_umount "${mnt}"
@@ -456,13 +465,13 @@ kexec_kernel() {
456465

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

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
468+
output="$( kexec -e -i 2>&1 )"
469+
470+
# If we ever reach this, it means our kexec failed
471+
zerror "kexec -e -i failed!"
472+
zerror "${output}"
473+
timed_prompt -d 10 -m "$( colorize red "kexec run of ${kernel} failed!" )"
474+
return 1
466475
}
467476

468477
# arg1: snapshot name

0 commit comments

Comments
 (0)