Skip to content

Commit

Permalink
Merge pull request sonic-net#25 from Azure/pavelsh/fast-reboot
Browse files Browse the repository at this point in the history
Add fast-reboot
  • Loading branch information
pavel-shirshov authored Mar 31, 2017
2 parents 5c59ec6 + 058959d commit 6482639
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions scripts/fast-reboot
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
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'scripts/boot_part',
'scripts/coredump-compress',
'scripts/decode-syseeprom',
'scripts/fast-reboot',
'scripts/generate_dump',
'scripts/portstat',
'scripts/sfputil',
Expand Down

0 comments on commit 6482639

Please sign in to comment.