Skip to content

Instantly share code, notes, and snippets.

Last active February 13, 2018 21:47
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chappy84/2787972 to your computer and use it in GitHub Desktop.
Save chappy84/2787972 to your computer and use it in GitHub Desktop.
Install the native kernel on a CentOS 6 and Newer Linode
### Starting from a fresh CentOS 6 or newer Linode
### Enable the native kernel to boot from pvgrub
### It will autoconfigure itself with each yum update.
### This is adapted from a previous script for CentOS 5.5 found here:
### Provided via the linode wiki
### Provided without warranty, although since it should only be run
### on first box build if your box gets broken simply rebuild it
mkdir /boot/grub/
AWK_VERSION_MATCH="{if(\$1==\"kernel.$DISTRO_PLATFORM\") print \$2}"
KERNEL_VERSION=`yum -q list kernel | awk "$AWK_VERSION_MATCH"`
### Write template grub.conf
cat > /boot/grub/grub.conf << EOF
# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initramfs paths are relative to /boot/, eg.
# root (hd0)
# kernel /boot/vmlinuz-version ro root=/dev/xvda
# initrd /boot/initramfs-version.img
root (hd0)
kernel /boot/vmlinuz-$KERNEL_VERSION.$DISTRO_PLATFORM root=/dev/xvda
initrd /boot/initramfs-$KERNEL_VERSION.$DISTRO_PLATFORM.img
ln -s /boot/grub/grub.conf /boot/grub/menu.lst
yum -y install kernel
if [ $? -ne 0 ]; then
echo "ERROR aborting..."
exit 1
Copy link

rwky commented Sep 20, 2016

I've found that on CentOS 6 /dev/xvda needs to be /dev/sda

Copy link

chappy84 commented Dec 11, 2016

@rwky specifically on Linode CentOS 6 builds or in general? If specifically on Linode this is possibly dependant on whether it's running on a Xen or KVM host, and the different CentOS 6 images Linode has for those

Copy link

As far as the above is concerned. Linode themselves now provide a couple of guides:
CentOS 6 with GRUB (Legacy):
CentOS 7+ using GRUB 2 on KVM host:
I'd encourage you to use GRUB 2 instead of this if you're using CentOS 7+ on a KVM host (most likely on KVM after the Meltdown / Spectre issues)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment