Last active
November 15, 2017 05:20
-
-
Save ebirn/11116953 to your computer and use it in GitHub Desktop.
kexec latest kernel on Centos 6
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
#!/bin/sh | |
VERSION=$(ls -t1 /boot/vmlinuz-* | cut -f 1 -d '-' --complement | head -1) | |
BOOT=/boot | |
KEXEC=/sbin/kexec | |
KERNEL=$BOOT/vmlinuz-$VERSION | |
INITRD=$BOOT/initramfs-$VERSION.img | |
COMMANDLINE=$(cat /proc/cmdline) | |
echo "detected values:" | |
echo " Kernel: $KERNEL" | |
echo " initrd: $INITRD" | |
echo "cmdline: $COMMANDLINE" | |
DOIT="$KEXEC -l $KERNEL --initrd=$INITRD --command-line=\"$COMMANDLINE\"" | |
echo "ready to run:" | |
while true; do | |
read -p "Do you wish to load kernel $VERSION for kexec? (y/n): " yn | |
case $yn in | |
[Yy] ) break;; | |
[Nn]* ) echo "user cancelled."; exit;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
# load the new kernel for real | |
echo $DOIT | |
$( "$DOIT" ) | |
echo "" | |
echo "ready for action:" | |
while true; do | |
read -p "Do you wish to exec kernel $VERSION? 'execute' or no: " yn | |
case $yn in | |
execute ) echo "executing new kernel NOW"; $KEXEC -e; break;; | |
* ) $KEXEC -u; echo "aborted."; break;; | |
esac | |
done | |
exit 0; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment