Skip to content

Instantly share code, notes, and snippets.

@joestringer
Created January 20, 2016 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joestringer/7dd29599fc3fb592bf79 to your computer and use it in GitHub Desktop.
Save joestringer/7dd29599fc3fb592bf79 to your computer and use it in GitHub Desktop.
Locate kernels available on the system and load one using kexec.
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: $0 <kernel>"
echo;
echo "Available kernels:"
ls /boot/vmlinuz-* | cut -d'-' -f2- | sed 's/^/ /'
exit 0;
fi
VERSION=$1
kexec -l /boot/vmlinuz-$VERSION --initrd=/boot/initrd.img-$VERSION --reuse-cmdline
if [ $? -eq 0 ]; then
echo "Loaded Linux-$VERSION. Run 'kexec -e' to execute it."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment