Diary of a geek

May 2006
Mon Tue Wed Thu Fri Sat Sun
7
       

Andrew Pollock

Categories

Other people's blogs

Subscribe

RSS feed

Contact me

JavaScript required


Sunday, 07 May 2006

Achieving Xen

I've been wanting to have a play with Xen for quite some time, but have a pathological dislike of compiling kernels, so hadn't gotten around to it. So needless to say, I'm very very (very very) pleased to see Xen 3.0 packages in Debian now, and so spent some time today having a fiddle.

Frankly, I'm very pleased with how easy it's been to get everything going.

Mad props to Steve Kemp for xen-tools, it makes the ease of creating a new DomU approach that of falling off a log. A big thanks also to the Debian kernel team for packaging this stuff up at last as well.

So, here's what I did:

I installed linux-image-2.6.16-1-xen-686 and xen-hypervisor-3.0-i386, along with the aforementioned xen-tools and xen-utils-3.0.

The linux-image-2.6.16-1-xen-686 kernel package doesn't create an initrd by default, so I created one by hand with mkinitramfs-kpkg.

I put this in my GRUB config:

title           Xen
root            (hd0,0)
kernel          /boot/xen-3.0-i386.gz
module          /boot/vmlinuz-2.6.16-1-xen-686 root=/dev/hda1 ro console=tty0
module          /boot/initrd.img-2.6.16-1-xen-686
boot

There's a couple of kernel images available that mention Xen, the aforementioned linux-image-2.6.16-1-xen-686 and also linux-image-2.6.16-1-xen-vserver-686. Unfortunately the package descriptions are the same as the stock 2.6.16 kernel package, and I initially formed the opinion that one was the Dom0 kernel and the other was the DomU kernel. It turns out that the linux-image-2.6.16-1-xen-686 will operate as either, and the vserver one will work as a DomU (I haven't tried it as a Dom0).

I'm currently using file-backed storage, but I want to switch to directly using LVM once I get the hang of things. I created the filesystem for the DomU with:

xen-create-image \
--hostname testvm \
--size 2Gb --swap 128Mb --memory 96Mb \
--fs ext3 --dir /srv \
--dhcp \
--cache yes --dist etch \
--mirror http://mirror.linux.org.au/debian \
--kernel /boot/vmlinuz-2.6.16-1-xen-vserver-686 \
--initrd /boot/initrd.img-2.6.16-1-xen-vserver-686

The one problem with this script is it puts SCSI (i.e. /etc/sda) devices in /etc/fstab, but refers to them as /dev/hda devices everywhere else. So to avoid a kernel panic on booting the DomU, I had to mount the image that was created and edit the /etc/fstab file to fix this up. I also needed to add vif = [ '' ] to get an eth0 interface to exist in the DomU instance. There's some other stuff you put here to use a consistent MAC address, rather than a per-instance-boot one.

I also found I needed to edit /etc/xen/xend-config.sxp to use network-bridge instead of network-dummy and vif-bridge. I found I needed to reboot as just restarting xend afterwards royally messed with the networking setup.

That was about it. Creating an instance of the VM then worked. Making sure the loop kernel module is loaded helps avoid some obscure errors.

[19:08] [tech] [permalink]