You can follow the instructions at http://www.howtoforge.com/perfect_setup_xen3_debian_p4 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/ \ http://ftp2.de.debian.org/debian chroot /mnt/vm_base/ apt-setup
Now edit /etc/apt/sources.list
and change testing
to stable
. Then continue with the setup:
apt-get update apt-get install localeconf base-config 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 address 127.0.0.1 netmask 255.0.0.0
And finally /etc/hosts
:
127.0.0.1 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:
exit 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:
name="vm01" kernel="/boot/vmlinuz-2.6.16-xen" root="/dev/hda1" memory=128 disk=['file:/mnt/cluster/xenamo/images/vm01.img,hda1,w','file:/mnt/cluster/xenamo/images/vm01-swap.img,hda2,w'] # network vif=[ '' ] dhcp="off" ip="10.0.0.1" netmask="255.255.255.0" gateway="10.0.0.254" hostname="vm01.example.com" extra="3"
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.
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>