Skip to content

Commit

Permalink
Update fast-reboot script to boot next selected image (sonic-net#112)
Browse files Browse the repository at this point in the history
* Update fast-reboot script to boot next selected image

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>

* Updated BOOT_OPTIONS

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>

* Renamed intermediate BOOT_OPTIONS to KERNEL_OPTIONS

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
  • Loading branch information
andriymoroz-mlnx authored and lguohan committed Oct 7, 2017
1 parent aa3254b commit 6103ce8
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,11 @@ then
fi

# Kernel and initrd image
KERNEL_IMAGE="/vmlinuz"
INITRD="/initrd.img"
BOOT_OPTIONS=$(cat /proc/cmdline)

case "$BOOT_OPTIONS" in
*fast-reboot*)
# it's already there
;;
*)
BOOT_OPTIONS="$BOOT_OPTIONS fast-reboot"
;;
esac
NEXT_SONIC_IMAGE=$(sonic_installer list | grep "Next: " | cut -d ' ' -f 2)
KERNEL_OPTIONS=$(cat /host/grub/grub.cfg | sed "/$NEXT_SONIC_IMAGE'/,/}/"'!'"g" | grep linux)
KERNEL_IMAGE="/host$(echo $KERNEL_OPTIONS | cut -d ' ' -f 2)"
BOOT_OPTIONS="$(echo $KERNEL_OPTIONS | sed -e 's/\s*linux\s*/BOOT_IMAGE=/') fast-reboot"
INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g')

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

Expand Down Expand Up @@ -67,4 +60,5 @@ sleep 1
sync

# Reboot
echo "Rebooting to $NEXT_SONIC_IMAGE..."
reboot

0 comments on commit 6103ce8

Please sign in to comment.