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.

Installation

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.

Configuration

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
address 10.10.10.100
netmask 255.255.255.0
network 10.10.10.0
broadcast 10.10.10.255
gateway 10.10.10.1
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   = 10.10.10.1
netmask   = 255.255.255.0
cache = no
passwd = 1
mirror = http://ftp.se.debian.org/debian/

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=10.10.10.101 –hostname=host1.chadda.se

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

xm create /home/xen/domains/host1.chadda.se/host1.chadda.se.cfg

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

Enjoy

Now enjoy your new virtualized server!

3 thoughts on “Run virtual servers using XEN”

  1. > xen-linux-system-2.6.18-6-xen-vserver-686

    Is there a reason you want to run linux-vservers under xen? I suspect most people would want the non-vserver version assuming they chose this route. You might also want to point out that this is a Debian Etch system on the i386 architecture. Other OS’s and architectures will have different package requirements. Other than that have fun with Xen.

Leave a Reply