Skip to content

Commit 93796b3

Browse files
Staphylolguohan
authored andcommitted
Add fast-reboot support for Aboot based images (sonic-net#214)
1 parent 924dd38 commit 93796b3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

scripts/fast-reboot

+12-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ fi
1616

1717
# Kernel and initrd image
1818
NEXT_SONIC_IMAGE=$(sonic_installer list | grep "Next: " | cut -d ' ' -f 2)
19-
KERNEL_OPTIONS=$(cat /host/grub/grub.cfg | sed "/$NEXT_SONIC_IMAGE'/,/}/"'!'"g" | grep linux)
20-
KERNEL_IMAGE="/host$(echo $KERNEL_OPTIONS | cut -d ' ' -f 2)"
21-
BOOT_OPTIONS="$(echo $KERNEL_OPTIONS | sed -e 's/\s*linux\s*/BOOT_IMAGE=/') fast-reboot"
19+
if grep -q aboot_platform= /host/machine.conf; then
20+
IMAGE_PATH="/host/image-${NEXT_SONIC_IMAGE#SONiC-OS-}"
21+
KERNEL_IMAGE="$(ls $IMAGE_PATH/boot/vmlinuz-*)"
22+
BOOT_OPTIONS="$(cat "$IMAGE_PATH/kernel-cmdline" | tr '\n' ' ') fast-reboot"
23+
elif grep -q onie_platform= /host/machine.conf; then
24+
KERNEL_OPTIONS=$(cat /host/grub/grub.cfg | sed "/$NEXT_SONIC_IMAGE'/,/}/"'!'"g" | grep linux)
25+
KERNEL_IMAGE="/host$(echo $KERNEL_OPTIONS | cut -d ' ' -f 2)"
26+
BOOT_OPTIONS="$(echo $KERNEL_OPTIONS | sed -e 's/\s*linux\s*/BOOT_IMAGE=/') fast-reboot"
27+
else
28+
echo "Unknown bootloader. fast-reboot is not supported."
29+
exit 1
30+
fi
2231
INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g')
2332

2433
sonic_asic_type=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)

0 commit comments

Comments
 (0)