• Sales: 1-800-961-2888
  • Support: 1-800-961-4454

Using a Custom Kernel with pv-grub


This article describes the steps required to modify an older first-generation Cloud Server to boot from a kernel installed in the instance using pv-grub.  Older first-generation servers load their kernel from the host machine by default unless modified to use pv-grub.

Next-generation servers and first-generation servers based on images created in 2011 or later should not need to perform these steps.  They should already be loading the kernel from /boot within the instance.

If your instance already has a kernel in /boot, you can see our article on Linux Kernel Management for an overview of managing and upgrading kernels for your server.

 

Contents

 

Obligatory Disclaimers

  • pv-grub is an advanced feature. It should only be used by experienced Linux administrators with a demonstrated need to run their own kernels.
  • This is only necessary for older first-generation servers that do not already include the kernel inside the instance. If you already have a kernel in /boot, it is likely your instance does not need to be modified to use pv-grub.
  • Not all kernels are supported. Your kernel must have pv-ops support for running in a Xen domU. Also, kernels compressed with bzip or LZMA will not work, and for some distributions like Arch compressed kernels may not work at all.
  • Follow the instructions as listed, in the order listed. Do not blindly copy/paste these commands, as some of them will require editing.
  • Do not attempt these instructions on a production system. If they are applied incorrectly, your Cloud Server may become unbootable. Practice on a clone of your server first.
  • This process is only compatible with the original version of GRUB, also referred to as GRUB Legacy. Our base images should only include GRUB Legacy, but a system update might install a newer version of GRUB (GRUB2) and need to be reverted to GRUB Legacy before this process will work.

 

Grub configuration

Every instance booted with pv-grub requires a working grub configuration file in /boot/grub/menu.lst:

default=0
timeout=5
 
title=DISTRO-NAME "KERNEL VERSION STRING"
    root (hd0)
    kernel /boot/KERNEL-VMLINUZ-FILENAME ro console=hvc0 root=/dev/xvda1
    initrd /boot/KERNEL-INITRD-FILENAME

 

Distribution-specific adjustments

Arch

pacman -Sy pacman
pacman -Sy base-devel
pacman -Syu
sed -i 's/sda/xvda/' /etc/fstab
pacman -Sy kernel26
mkdir -p /boot/grub
cp /usr/src/KERNEL-VERSION/vmlinux /boot/vmlinux26

Note: The stock arch kernel is bzipped and won't work with pv-grub. Use the uncompressed vmlinux instead.

Now add (or uncomment) the following line in /etc/inittab for console:

h0:2345:respawn:/sbin/agetty -8 38400 hvc0 linux

CentOS 5.x

yum -y upgrade
mkdir -p /boot/grub
echo "alias eth0 xennet" > /etc/modprobe.conf
echo "alias eth1 xennet" >> /etc/modprobe.conf
echo "alias scsi_hostadapter xenblk" >> /etc/modprobe.conf
echo "xvc0" >> /etc/securetty
sed -i 's/sda/xvda/' /etc/fstab
yum -y install kernel-xen

Now add (or uncomment) the following line in /etc/inittab for console:

8:2345:respawn:/sbin/mingetty xvc0

Debian 5.x

apt-get update; apt-get -y upgrade
mkdir /boot/grub
sed -i 's/sda/xvda/' /etc/fstab
apt-get -y install linux-image-xen-amd64

Now add (or uncomment) the following line in /etc/inittab for console:

8:2345:respawn:/sbin/getty 38400 hvc0

Fedora 13

mkdir -p /boot/grub
echo "alias eth0 xennet" > /etc/modules
echo "alias eth1 xennet" >> /etc/modules
echo "alias scsi_hostadapter xenblk" >> /etc/modules
sed -i 's/sda/xvda/' /etc/fstab
echo "hvc0" >> /etc/securetty
yum -y install kernel

Gentoo

emerge --sync
emerge --update portage
emerge gentoo-sources genkernel #Update /usr/src/linux symlink if necessary
sudo sed -i 's/sda/xvda/' /etc/fstab
genkernel --menuconfig all

Enable the following in the kernel configuration:

Processor Type and Features -> Paravirtualized guest support -> "Y"
Hit enter, go to "Xen guest support" -> "Y"

Then exit the configuration, save, and build.

Now add (or uncomment) the following line in /etc/inittab for console:

h0:12345:respawn:/sbin/agetty 38400 hvc0 linux

RHEL 5.x

yum -y upgrade
mkdir -p /boot/grub
echo "alias eth0 xennet" > /etc/modprobe.conf
echo "alias eth1 xennet" >> /etc/modprobe.conf
echo "alias scsi_hostadapter xenblk" >> /etc/modprobe.conf
echo "xvc0" >> /etc/securetty
sed -i 's/sda/xvda/' /etc/fstab
yum -y install kernel-xen

Now add (or uncomment) the following line in /etc/inittab for console:

8:2345:respawn:/sbin/mingetty xvc0

Ubuntu 9.10/10.04

mkdir /boot/grub
cp /etc/init/tty1.conf /etc/init/hvc0.conf
sed -i 's/tty1/hvc0/' /etc/init/hvc0.conf
sed -i 's/sda/xvda/' /etc/fstab
apt-get -y install linux-virtual

Ubuntu 10.10

mkdir /boot/grub
cp /etc/init/tty1.conf /etc/init/hvc0.conf
sed -i 's/tty1/hvc0/' /etc/init/hvc0.conf
apt-get -y install linux-virtual

Kernel upgrade

Contact Rackspace Cloud support and request the pv-grub feature, informing them that you have completed these steps and would like to use your own kernel. Your Cloud Server will be rebooted, and -- if all goes well -- will come back up with your new kernel. You may verify this with 'uname -a'.







© 2011-2013 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License


See license specifics and DISCLAIMER