Monday, December 6, 2010

Installing Xen 4.0.1 and testing on Ubuntu 10.04

Several of my colleagues have recently had a great time trying to install Xen on Ubuntu. I've seen various locations where the task has been partially done, but the authors always leave something missing. I guess in their cases, the goal is to get their job done and not make a very generic tutorial. The goal of this tutorial is to be generic, so that the process can be repeated easily without going having to return to google to figure out what the contents of this tutorial are expressing.

So here's a rough outline:

Install or having a working Ubuntu 10.04. If you are doing a fresh install, I recommend using ext3 on your hard disks otherwise you'll have to reconfigure the Xen-Linux kernel.

Install the necessary utilities to download, compile, and install Xen:apt-get install bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial build-essential make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml libx11-dev

If you are using 32-bit install libc6-xen (This will get rid of the annoying TLS segmentation message): apt-get install libc6-xen

If you are using 64-bit install 32-bit utils: apt-get install gcc-multilib

Download Xen, either get the Xen 4.0.1 source or get testing. If you want the 4.0.1 source, its faster to download the tar.gz than the entire mecurial repository!

4.0.1 source: wget

Testing source: hg clone

Build Xen, this includes building all tools but not the Xen-Linux Kernel:
cd into the Xen dir
make xen
make tools
make stubdom
make install-xen
make install-tools PYTHON_PREFIX_ARG=
make install-stubdom

Build the Xen-Linux Kernel (if you need to configure the kernel see the bottom of this post):

make prep-kernels
Optionally configure the kernel especially if you are using ext4 (see below)
make kernels
make install-kernels

Figure out kernel version by looking at the .config file in the kernel build path (typically starts with: build-linux-2.6-pvops_), so typing "head build-linux-2.6-pvops_x86_32/.config" in 32-bit case will print out the "Linux kernel version" near the top (the current version is

update-initramfs -c -k [kernel version]

Making Xend auto-start:

update-rc.d xend defaults 20 21

Update Grub

Place this in /etc/grub/40_custom:

menuentry "Xen-Testing - Linux" {
insmod ext2
set root="(hd0,1)"
multiboot /boot/xen.gz dom0_mem=256M
module /boot/vmlinuz- ro nomodeset root=UUID=24aece87-9b12-4966-8c04-4bd59d5808ae
module /boot/initrd.img-
Note: you can obtain your disks partition (hd0,1) by running blkid on the device, the default device will usually be /dev/sda1 (e.g., blkid /dev/sda1). Also feel free to adjust dom0_mem

Finally update grub:

Reboot into Xen. While testing you should leave the default boot into your regular kernel. Hold shift during reboot to access a grub menu and select Xen. Determine which grub entry Xen, hint, they are incremented in order from 0 to N. In my case, it was 6, so edit the /etc/default/grub and replace 0 with 6 on the line "GRUB_DEFAULT". The next step is to create a domU!