Fedora 15 with stock kernel on Rackspace Cloud

I recently found myself needing a more bleeding-edge cloud server than the Fedora 14 servers I have been running on Rackspace Cloud. Rackspace is not yet offering a Fedora 15 image for new servers, so I needed to start with a Fedora 14 system and upgrade it. I also needed the kernel to be more current than the 2.6.34.1 kernel Rackspace currently uses with Fedora images, and I am not sure the upgraded userspace would work with that kernel and init image pair anyway. This meant I needed to use PV-GRUB to use the stock Fedora kernel. What follows is a description of the process I used to get Fedora 15 running with the stock Fedora kernel on Rackspace Cloud. Rackspace Cloud, like Amazon AWS and many other VPS providers, uses the Xen hypervisor. Under a typical configuration, custom kernel and init images are used for each VPS, rather than images stored within the VPS. The kernel used with Rackspace's Fedora 14 image is a custom kernel built on Ubuntu. Thankfully, Rackspace does allow operators to use PV-GRUB to load other kernels. If you are considering trying this process on a production system, seek therapy. Start with a new server and migrate your services once you're done. If this doesn't go smoothly, you could be left with a server that will not boot and no recourse but to restore a backup.

Quick Overview

The general process goes something like this:

  • Set up a new server with Rackspace's Fedora 14 image
  • Configure the system to run as a Xen domU loaded by PV-GRUB
  • Install the Fedora kernel
  • Contact Rackspace to enable PV-GRUB
  • Upgrade the system to Fedora 15

Before the Kernel

The fist step is to set up a server loaded from Rackspace's Fedora 14 image to run as a Xen domU loaded by PV-GRUB.

cat >> /etc/modprobe.d/domu.conf << EOF
alias eth0 xennet
alias eth1 xennet
alias scsi_hostadapter xenblk
EOF
sed -i 's/sda/xvda/g' /etc/fstab
echo "hvc0" >> /etc/securetty

Install the Kernel

The next step is to install the Fedora stock kernel.

yum install kernel

Take note of the kernel version. You'll need it in the next step. You can get the exact version string you need with this command:

rpm -q kernel --qf '%{version}-%{release}.%{arch}\n'

Time to create the configuration file required by PV-GRUB. We'll create this as grub.conf and create a symlink at menu.lst, which is how the grub configuration is normally created on Fedora. In the following, replace "$KERNELVERSION" with the correct kernel version string.

mkdir -p /boot/grub
cat >> /boot/grub/grub.conf << EOF
#boot=/boot/grub/stage1
default=0
timeout=1

title Fedora ($KERNELVERSION)
        root (hd0)
        kernel /boot/vmlinuz-$KERNELVERSION ro console=hvc0 root=/dev/xvda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us
        initrd /boot/initramfs-$KERNELVERSION.img
EOF
ln -s ./grub.conf /boot/grub/menu.lst

Since we're going to use the stock Fedora kernel, we can set things up for yum to handle kernel updates and have the grub.conf file updated automatically. The commented-out boot directive in our grub.conf is part of this configuration. To finish this setup, we'll need to install grub and grubby and create a few more configuration items.

yum install grub grubby
cp /usr/share/grub/x86_64-redhat/stage1 /boot/grub/stage1
ln -s ../boot/grub/grub.conf /etc/grub.conf
cat >> /etc/sysconfig/grub << EOF
boot=/boot/grub/stage1
forcelba=0
EOF
cat >> /etc/sysconfig/kernel << EOF
# UPDATEDEFAULT specifies if new-kernel-pkg should make
# new kernels the default
UPDATEDEFAULT=yes

# DEFAULTKERNEL specifies the default kernel package type
DEFAULTKERNEL=kernel
EOF

Test that grubby detects grub.

grubby --bootloader-probe

Enable PV-GRUB

At this point, it's time to contact Rackspace Support to enable PV-GRUB. They will enable PV-GRUB and reboot your server. With a little luck, you server will start up with your stock kernel. Reconnect to your server and verify.

uname -a

At this point, you should consider creating an on-demand backup.

Upgrade to Fedora 15

Now that you are running on the stock Fedora 14 kernel, you are ready to upgrade your server to Fedora 15 (and its kernel). The general Fedora guidance is here: https://fedoraproject.org/wiki/Upgrading_Fedora_using_yum Because we're dealing with a cloud server with PV-GRUB, there will be a few differences. You won't be switching to a text console or changing runlevels. You will not want to install the other Base packages. You cannot write a new MBR with grub-install. Really, our process is much simpler. To be safe, we'll use screen to launch our upgrade to mitigate the risk of a disconnect. (I recommend always using screen when using yum or doing anything else critical over SSH.)

yum install screen
screen -h 10000 -S yum

This screen command will increase the default history size and name the session for easy access. If you become disconnected during the upgrade, connect to the server again and run the following command to attach to your screen session:

screen -rx yum

Time to perform the upgrade.

rpm --import https://fedoraproject.org/static/069C8460.txt
yum update yum
yum clean all
yum --releasever=15 --disableplugin=presto distro-sync
cd /etc/rc.d/init.d; for f in *; do /sbin/chkconfig $f resetpriorities; done
ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target

Make sure that the new Fedora 15 kernel is configured and set as default in /boot/grub/grub.conf.

Profit

Reboot. A little more luck and your server will come back up running the new Fedora 15 kernel and userspace. You may want to create an on-demand backup at this point. You can reuse this image to create more Fedora 15 servers, but do not forget to contact Rackspace Support to enable PV-GRUB for each instance. If you created an on-demand backup after getting Fedora 14 running with PV-GRUB, you can now delete that image. Have I missed anything? Let me know.

Comments

Thanks a bunch. This worked perfectly for me.