Setting up virtual machines (domU's)

You can follow the instructions at in order to setup a Debian Sarge domU:

mkdir -p /mnt/cluster/xenamo/images
mkdir -p /mnt/cluster/xenamo/config
dd if=/dev/zero of=/mnt/cluster/xenamo/images/vm_base.img \
 bs=1024k count=1000
dd if=/dev/zero of=/mnt/cluster/xenamo/images/vm_base-swap.img \
 bs=1024k count=500
mkfs.reiserfs /mnt/cluster/xenamo/images/vm_base.img
mkswap /mnt/cluster/xenamo/images/vm_base-swap.img
mkdir /mnt/vm_base
mount -o loop /mnt/cluster/xenamo/images/vm_base.img /mnt/vm_base
debootstrap --arch i386 sarge /vserver/vm_base/ \
chroot /mnt/vm_base/

Now edit /etc/apt/sources.list and change testing to stable. Then continue with the setup:

apt-get update
apt-get install localeconf
apt-get remove nfs-common
rm -f /etc/hostname

Next you need to edit /etc/fstab. It should look like this:

/dev/hda1  /       ext3  defaults   1 2
/dev/hda2  none    swap  sw         0 0
/dev/pts   devpts  gid=5,mode=620   0 0
none     /dev/shm  tmpfs defaults   0 0

Then, /etc/network/interfaces needs to be created:

auto lo
iface lo inet loopback

And finally /etc/hosts:       localhost.localdomain   localhost
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Now, you can leave the chroot environment and finalize the setup:

cp -dpR /lib/modules/2.6.16-xen /mnt/vm_base/lib/modules/
mv /mnt/vm_base/lib/tls /mnt/vm_base/lib/tls.disabled
umount /mnt/vm_base

The created image file can be used as a domU template. To create the first domU, do:

cd /mnt/cluster/xenamo/images
cp -pf vm_base.img vm01.img
cp -pf vm_base-swap.img vm01-swap.img
cd /mnt/cluster/xenamo/config
nano vm01.sxp

Create now your first domU config file. It should look like this:

memory=128 disk=['file:/mnt/cluster/xenamo/images/vm01.img,hda1,w','file:/mnt/cluster/xenamo/images/vm01-swap.img,hda2,w']
# network vif=[ '' ]

Doing your first live migration

Preparing Xen

In order that you can migrate domU's to other Xen hosts, you must configure Xen to allow connections from the other hosts. To do so, edit the file /etc/xen/xend-config.sxp and change the lines containing the following information:

(xend-relocation-server yes)
(xend-relocation-allow '')

This allows all connections to this Xen host. But you can enter any regular expression or IP address. You can find examples inside of the config file.

Start, stop and live migrate your domU's

To start the previously configured domU, execute the following command:

xm create -c /mnt/cluster/xenamo/config/vm01.sxp

The -c parameter brings you to the console of this virtual machine. Like this, you can follow the boot process. Press Ctrl-] to leave the console and return to the dom0. Entering xm list shows you the state of the currently running domU's on this host. In order to migrate a domU, you need the corresponding ID. Now, do your first live migration:

xm migrate --live <id> <hostname>