I have been playing with Xen a bit recently for quick prototyping of clusters of machines. It seems to work quite well on SuSE 9.3. The following is how I made it work

First of all you need to install the xen specific patches from your SuSE source media. They are all selectable through yast. For reference the ones I installed are shown below, the version numbers might not match the ones on the DVD because I have applied some recommended updates to my machine (including a newer kernel).


The next thing to do is to make yast update your boot loader config based on the new xen kernels. This can be done by running yast and choosing System -> Boot Loader Configuration -> Reset -> Propose New Configuration. Once it has written the new boot loader configuration you will need to select the XEN kernel as the default (Xen needs kernel support on the host as well as the virtual machines). When that has been done reboot your box with the new Xen equiped kernel.

Now you are running on the new Xen kernel, add xend to the system startup (chkconfig --add xend)

The next stage is to make yast install itself into a directory ready for use as the root filesystem of the Xen virtual machine. if you go into yast and choose Software -> Installation into Directory for XEN It will prompt you for some options, I accepted all the defaults apart from changing the Software to be a ‘minimum system’. You can see what my options looked like below:

Note: there seems to be an image to create an image but it didnt seem to work for me.

When this has completed you should have what looks like a root filesystem in /var/tmp/dirinstall now you need to get that into a ext2 filesystem image. This can be done as shown below:

# cd /u01/xen
# dd if=/dev/zero of=xen1-rootfs bs=1k seek=2048k count=1
# dd if=/dev/zero of=xen1-swap bs=1024k count=512
# mkswap xen1-swap
# mke2fs xen1-rootfs
# mount -t ext2 -o loop /u01/xen/xen1-rootfs /mnt/tmp
# cd /var/tmp/dirinstall
# find . | cpio -p /mnt/tmp
# umount /mnt/tmp

The commands above (in order) are doing the following:

  1. cd into the directory where I keep my xen disk images
  2. create a 2Gb sparse file image for the root filesystem
  3. create a 512 meg swap file image
  4. makes the swap image actually readable as swap to linux
  5. put a ext2 filesystem on the root image
  6. mount the root image on /mnt/tmp (this can be any temporary mount point of your choice)
  7. cd into the recently installed SuSE directory
  8. use find and cpio to copy the entire tree into the mounted image
  9. unmounting the image

Now that you have a image file you can create a Xen config file. mine is shown below:

# cat /etc/xen/xen1
kernel = "/boot/vmlinuz-"
memory = 64
name = "xen1"
nics = 1
vif = [ 'bridge=xen-br0' ]
disk = ['file:/u01/xen/xen1-root,sda1,w','file:/u01/xen/xen1-swap,sda2,w']
root = "/dev/sda1 rw"
hostname= "xen1"

Note the kernel line must match whichever version you are running in /boot and the paths to the disk images must match your locations. This file (on my system) was called xen1 and was in /etc/xen/

Now you are almost ready to start your virtual machine, before I started mine I added a fstab, copied over my passwd, group and shadow files and created a config file for eth0. To anything to your disk image you must first mount it:

# mount -t ext2 -o loop /u01/xen/xen1-rootfs /mnt/tmp

and copy across a few useful files:

# cp /etc/{shadow,group,passwd,resolv.conf} /mnt/tmp/etc

I also created a /etc/fstab file inside my disk image which looked like this:

/dev/sda1       /       ext3    errors=remount-ro       0       1
/dev/sda2       none    swap    sw                      0       0
proc            /proc   proc    defaults                0       0

Also create yourself a ifcfg-eth0 file so that networking is brought up on startup, mine looks like the one below change the ip address etc to suit:

# cat /mnt/tmp/etc/sysconfig/network/ifcfg-eth0
NAME='Ethernet Network Card'

When that is done, umount the disk image (remember to cd out of any directory below /mnt/tmp first):

# umount /mnt/tmp

Now you are ready to start your Xen virtual domain:

# xm create xen1 -c

If all goes well you should see what looks like a kernel booting and it will drop you at a login prompt, because we copied over your local passwd and shadow files you should be able to just login. There are some services which need turning off because they dont play well inside the VM (like the HW clock etc) but you can simply disable these by running yast when your virtual machine has booted.

There is a whole lot of extra stuff you can do with xen but all of that is outside scope of this document, I wanted to keep this as a short ‘How I made it work on Suse 9.3’ for more information check the documentation linked from the Xen home page at http://www.cl.cam.ac.uk/Research/SRG/netos/xen/