Managing Xen With Xen-Tools, Xen-Shell, And Argo
Author: Falko Timme
This guide describes how to install and use xen-tools, xen-shell, and Argo on a Debian system. All three packages provide useful tools for the administration of virtual Xen machines. Xen-tools is a collection of Perl scripts that allow you to easily create, update, and delete Xen guest domains. The xen-shell provides a command-line interface to owners of Xen domains so that they can manage their Xen domains without the help of the server administrator. And with Argo, you can control Xen domains through a web interface or through a menu on the command line. All three packages were developed for Debian systems, but might work on other distributions as well.
I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!
1 Preliminary Note
I assume you have already installed Xen 3 on your Debian system (it doesn't work with Xen 2!), for example from the sources as shown in chapter 4 of this tutorial: https://www.howtoforge.com/debian_sarge_xen_3.0.3. I couldn't get xen-tools to work with the binary Xen installation (shown in chapter 5), but it might work for you. But xen-tools work like a charm for me on a Xen installation from the sources.
The hostname of my Xen dom0 domain is server1.example.com in this tutorial, its IP address is 192.168.0.100, and the gateway is 192.168.0.1. I want to store my guest domains in the /vserver/images directory. These values might be different for you.
Please make sure you have a line like this one in /etc/hosts:
[...] 192.168.0.100 server1.example.com server1 [...]
Although there are Debian packages for xen-tools and xen-shell available on http://www.steve.org.uk/apt/, I decided to install xen-tools and xen-shell from the sources because the xen-tools Debian package wrote invalid Xen configuration files for me which didn't happen when I used the sources.
First we install some prerequisites for xen-tools:
apt-get install libtext-template-perl perl-doc
Then we install xen-tools like this:
tar xvfz xen-tools-2.7.tar.gz
Next we edit /etc/xen-tools/xen-tools.conf. This file contains the default values that are used by the xen-create-image script unless you specify other values on the command line. I changed the following values and left the rest untouched:
[...] gateway = 192.168.0.1 netmask = 255.255.255.0 passwd = 1 kernel = /boot/vmlinuz-2.6-xenU #initrd = /boot/initrd.img-2.6.16-2-xen-686 mirror = http://ftp2.de.debian.org/debian/ [...]
The passwd = 1 line makes that you can specify a root password when you create a new guest domain. In the kernel line you must specify the domU kernel that you want to use for your guest domains. If your guest domains don't need a ramdisk to boot up, comment out the initrd line (I had to do this on my installation), otherwise specify the correct ramdisk. In the mirror line specify a Debian mirror close to you.
Make sure you specify a gateway and netmask. If you don't, and you don't specify a gateway and netmask on the command line when using xen-create-image, your guest domains won't have networking even if you specified an IP address!
Now let's create our first guest domain, vm03.example.com, with the IP address 192.168.0.103:
xen-create-image --hostname=vm03.example.com --ip=192.168.0.103 \
--netmask=255.255.255.0 --gateway=192.168.0.1 --dir=/vserver/images \
The --netmask and --gateway switches are unnecessary here because we specified the same details in /etc/xen-tools/xen-tools.conf but it shows that you can specify the desired settings either on the command line or in /etc/xen-tools/xen-tools.conf.
This command will now create the guest domain vm03.example.com with Debian Sarge in it by using Debian's debootstrap tool. This will take some minutes so be patient. In the meantime you can open up another shell window and run
tail -f /var/log/xen-tools/vm03.example.com.log
to see what's happening behind the scenes.
After the new guest domain has been created, check /etc/xen/vm03.example.com.cfg. It should now look like this (I've stripped out the comments here):
kernel = '/boot/vmlinuz-2.6-xenU' memory = '128' root = '/dev/sda1 ro' disk = [ 'file:/vserver/images/domains/vm03.example.com/disk.img,sda1,w', 'file:/vserver/images/domains/vm03.example.com/swap.img,sda2,w' ] name = 'vm03.example.com' vif = [ 'ip=192.168.0.103' ] on_poweroff = 'destroy' on_reboot = 'restart' on_crash = 'restart'
We can start our new virtual machine like this:
xm create -c /etc/xen/vm03.example.com.cfg
With the xen-create-image command, you can specify almost all settings on the command line. Have a look at
to find out more. Here's another example:
xen-create-image --size=2Gb --swap=128Mb --hostname=vm04.example.com \
--ip=192.168.0.104 --netmask=255.255.255.0 --gateway=192.168.0.1 --dir=/vserver/images \
--dist=sarge --debootstrap --fs=ext3 --kernel=/boot/vmlinuz-2.6-xenU --memory=32Mb \
--image=sparse --mirror=http://ftp2.de.debian.org/debian/ --passwd
This will create the virtual domain vm04.example.com. /etc/xen/vm04.example.com.cfg should look like this afterwards (again, I've stripped out the comments):
kernel = '/boot/vmlinuz-2.6-xenU' memory = '32' root = '/dev/sda1 ro' disk = [ 'file:/vserver/images/domains/vm04.example.com/disk.img,sda1,w', 'file:/vserver/images/domains/vm04.example.com/swap.img,sda2,w' ] name = 'vm04.example.com' vif = [ 'ip=192.168.0.104' ] on_poweroff = 'destroy' on_reboot = 'restart' on_crash = 'restart'
You can start the new virtual machine like this:
xm create -c /etc/xen/vm04.example.com.cfg
There are also three other scripts that come with xen-tools:
xen-update-image lets you update the packages in guest domains, e.g. like this:
xen-update-image --dir=/vserver/images vm03.example.com
xen-list-images shows all guest domains that were created with xen-create-image:
The output looks like this:
With xen-delete-image you can remove guest domains that were created with xen-create-image:
xen-delete-image --dir=/vserver/images vm03.example.com