TSG-16020: 通过kexec进行快速内核切换跳过硬件检查加快升级流程

This commit is contained in:
linxin
2023-07-19 18:02:12 +08:00
committed by 林鑫
parent e68336b2be
commit fc5aae23fe
2 changed files with 49 additions and 6 deletions

View File

@@ -4,10 +4,36 @@
#
# SPDX-License-Identifier: GPL-2.0
. /lib/onie/common-blkdev
echo "Rebooting into ONIE (re)install mode..."
# Check for --no-kexec argument
if [ "$1" = "--no-kexec" ]
then
. /lib/onie/common-blkdev
set_onie_next_boot
/mnt/onie-boot/onie/tools/bin/onie-boot-mode -q -o install
reboot
echo "Rebooting into ONIE (re)install mode..."
set_onie_next_boot
/mnt/onie-boot/onie/tools/bin/onie-boot-mode -q -o install
echo "Rebooting with reboot command..."
reboot
else
echo "Rebooting with kexec command..."
# Find vmlinuz and initrd files in /mnt/onie-boot
vmlinuz_file=$(find /mnt/onie-boot -name 'vmlinuz*' | head -n 1)
initrd_file=$(find /mnt/onie-boot -name 'initrd*' | head -n 1)
if [ -z "$vmlinuz_file" ] || [ -z "$initrd_file" ]
then
echo "Error: vmlinuz or initrd file not found. Falling back to reboot command."
reboot
else
# Get current kernel command line parameters
current_kernel_params=$(cat /proc/cmdline)
# Load the kernel and initrd using kexec
kexec -l "$vmlinuz_file" --initrd="$initrd_file" --append="fastreboot=1 $current_kernel_params"
# Execute kexec
kexec -e
fi
fi