forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sonic-net#25 from Azure/pavelsh/fast-reboot
Add fast-reboot
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# Check root privileges | ||
if [ "$EUID" -ne 0 ] | ||
then | ||
echo "Please run as root" | ||
exit | ||
fi | ||
|
||
# Unload previous kernel if any loaded | ||
if [ $(cat /sys/kernel/kexec_loaded) -eq 1 ] | ||
then | ||
/sbin/kexec -u | ||
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 | ||
|
||
# Load kernel into memory | ||
/sbin/kexec -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$BOOT_OPTIONS" | ||
|
||
# Stop docker container engine. Otherwise will have broken docker storage | ||
systemctl stop docker.service | ||
|
||
# Wait until all buffers synced with disk | ||
sync | ||
sleep 3 | ||
sync | ||
|
||
# Reboot | ||
reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters