Xen Linux kernel configuration for dummies

First let me offer my apologies to readers on GUFF or Facebook: normal service will resume shortly. Now, who’s been having trouble with their paravirtualisation?

It seems to me a common problem that when people try to build Xen from source, they come unstuck when trying to boot their new dom0 kernel. Usually, they get an error like:

VFS: Cannot open root device “hda1″ or unknown-block(0,0)

Obviously, or maybe not, hda1 could be replaced by a number of different labels. What it boils down to is that your kernel and initial ramdisk pairing is incorrectly configured to access your root device. And so you can’t get to any of your files.

The first step is to make sure that you have an initial ramdisk. And this is where the advice usually ends. So, boot up your system using a functioning kernel, and enter the following as root (assuming your version of Xen uses 2.6.18 as the dom0 kernel):

mkinitrd -f /boot/initrd-2.6.18-xen.img 2.6.18-xen

Then edit your GRUB menu.lst to make sure that this is being loaded (it should be on a line beginning “module”, immediately following your dom0 kernel).

In many cases, this will fix the problem, but not if you didn’t build the correct modules in the first place! What you have to do, then, is get a copy of a working kernel .config for your system. For example, if you set up Fedora Core 5, you should be able to get a copy of the FC5 .config files for your kernel version (2.6.15, in my case). Follow the instructions for downloading kernel headers sources, and you should find them in a resulting directory. If you’re extra-lucky, you might get specific Xen .config files (for the distributions that ship with Xen support). Now that you have a working configuration, copy this over $XENROOT/buildconfigs/linux-defconfig_xen_x86_32 (use your smarts to select the appropriate source file for your architecture, and modify your move-target appropriately).
Now, hit `make world`, and go and make some coffee. Do the same mkinitrd shuffle as before, then reboot into Xen. If you’re lucky like me, it’ll work.

I know that this might be obvious to anyone who’s done serious kernel development before, but it wasn’t to me, and maybe you’ll come across this page in Google and it’ll help you out.

A little aside: I was doing all this in order to get Xen to run in HVM mode, on top of Xen. A big hat-tip must therefore go to Mark Williamson, who set me on this path and helped me out along the way.
As for the blog, expect normal service to return, with a mild rant about customer service and the iniquities of pedestrian access to suburban shopping centres, real soon now….

Leave a Reply