in Technology

Run virtual servers using XEN

Running virtual servers may save you a bundle on server costs, but in the same time create a more secure environment by separating services into logical hosts. This guide will show you how to setup a XEN virtual server using Debian, but it may also be used on Ubuntu if that it preferred.


The first task is to install all required software packages. Installing the virtual xen package will in turn install all required programs like a new libc6, kernel with virtual support and the xen hypervisor. Installing xen-tools makes it very easy to create new virtual servers.

# aptitude install xen-linux-system-2.6.18-6-xen-vserver-686 xen-tools

After installing the new kernel and libs, you will need to reboot the computer to use it.


The virtual hosts need some way to access the network, so we have to create a network bridge for them to use. Open the file /etc/network/interfaces and create a section like the following. Be sure to change the network settings to reflect your own network.

iface xenbr0 inet static
bridge_ports eth0

Open up the xen configuration file /etc/xen/xend-config.sxp in your favorite editor and make the following changes.

(network-script network-bridge)
(vif-script vif-bridge)
(dom0-min-mem 196)
(dom0-cpus 0)

The configuration file contains lots of comments, so I will not go into detail about every change.

The last configuration is for the xen-tools package /etc/xen-tools/xen-tools.conf, which we will use to create the virtual machines. Be sure to change the network settings and home directory to match your envionment.

dir = /home/xen
dist   = etch
gateway   =
netmask   =
cache = no
passwd = 1
mirror =

The rest of the values can probably be left alone, but do take a look at them to see if you need to custmize anything.

Now to create a new virtual host, just write the following and debootstrap should start installing a fresh Debian system.

xen-create-image –ip= –

When the installation part is finished, just start the host (or create in xen speak), using the following command.

xm create /home/xen/domains/

If you add the -c option, you will attach to the virtual console and you will see all output from the guest.


Now enjoy your new virtualized server!