This is a "copy & paste" HowTo! The easiest way to follow this tutorial is to use a command line client/SSH client (like PuTTY for Windows) and simply copy and paste the commands (except where you have to provide own information like IP addresses, hostnames, passwords,...). This helps to avoid typos.

The Perfect Xen Setup For Debian And Ubuntu

Version 1.1
Author: Falko Timme

This tutorial provides step-by-step instructions on how to install Xen (version 2; I have not tested this with version 3 yet) on a Debian Sarge (3.1) system. It should apply to Ubuntu systems with little or no modifications.

Xen lets you create guest operating systems (*nix operating systems like Linux and FreeBSD), so called "virtual machines" or domUs, under a host operating system (dom0). Using Xen you can separate your applications into different virtual machines that are totally independent from each other (e.g. a virtual machine for a mail server, a virtual machine for a high-traffic web site, another virtual machine that serves your customers' web sites, a virtual machine for DNS, etc.), but still use the same hardware. This saves money, and what is even more important, it's more secure. If the virtual machine of your DNS server gets hacked, it has no effect on your other virtual machines. Plus, you can move virtual machines from one Xen server to the next one.

I will use Debain Sarge for both the host OS (dom0) and the guest OS (domU). In an additional section at the end I will also show how to create a virtual local network with virtual machines, with dom0 being the router.

This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.

This document comes without warranty of any kind! I want to say 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 Install The Debian Host System (dom0)

You can overall follow these instructions, but with a few changes:

However, it's important that you type linux26 at the boot prompt to install a kernel 2.6 system. dom0's FQDN in this example will be, so I specify server1 as Hostname and as Domain name.'s IP address will be in this tutorial.

When it comes to the partitioning, I select Manually edit partition table. I create the following partitions:

  • /boot 100 MB (Primary) (Location for the new partition: Beginning) (ext3) (Bootable flag: on <-- important, otherwise your system will not boot!)
  • swap 1GB (Logical) (Location for the new partition: Beginning)
  • / 2GB (Logical) (Location for the new partition: Beginning) (ext3)
  • /vserver the rest (Logical) (Location for the new partition: Beginning) (ext3)

(Side note: You can also install everything in one big partition (as described here:, but then you have to keep in mind that the Grub stanzas I describe in this howto are slightly different. For example, when I write that I add

title        Xen 2.0.6 / XenLinux
root (hd0,0)
kernel /xen.gz dom0_mem=65536
module /vmlinuz- root=/dev/hda6 ro console=tty0

to /boot/grub/menu.lst then you should probably use

title        Xen 2.0.7 / XenLinux
root (hd0,0)
kernel /boot/xen.gz dom0_mem=65536
module /boot/vmlinuz- root=/dev/hda1 ro console=tty0

in that file...)

When the Debian installer prompts Choose software to install: I make no selection and go on (dom0 should run as few software as possible in order not to be vulnerable to attacks. To the outside world it will be accessible only over SSH.).

2 Configure dom0's Network

Because the Debian Sarge installer has configured our system to get its network settings via DHCP, we have to change that now because a server should have a static IP address. Edit /etc/network/interfaces and adjust it to your needs (in this example setup I will use the IP address

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static

Then restart your network:

/etc/init.d/networking restart

Edit /etc/resolv.conf and add some nameservers:

search server

Then set dom0's hostname:

echo > /etc/hostname
/bin/hostname -F /etc/hostname

3 Install Xen

There are two ways to install Xen: install the binary package from the Xen website, or compile Xen and the Xen kernels from the sources.

The first way is easier, but it has the disadvantage that the domU kernel that comes with the binary package has no support for quota and iptables, both features that I need in my virtual machines (domU). Plus, the dom0 kernel has no support for the dummy network driver, which I need at the end in the optional chapter 5 where I describe how to set up a virtual local network with virtual machines.

In chapter 3.1 I describe how to install the Xen binary package which is recommended for beginners (skip chapter 3.2 and continue with chapter 4). If you need quota and iptables in your virtual machines, then skip chapter 3.1 and continue with chapter 3.2 where I show how to install Xen from the sources.

Share this page:

4 Comment(s)

Add comment

Please register in our forum first to comment.


By: Anonymous

This has been a very helpful howto. Thanks for creating it. A follow up for xen 3 would be appreciated!

By: Anonymous


can you change this (on first page):


echo > /etc/hostname


to this:


echo server1 > /etc/hostname


Quote from `man hostname':

       /etc/hosts /etc/hostname This file should only contain domain name and not the full FQDN.

Thank you.
(i didn't want to create an account to be able to send an email...) ;-)

By: don burch

How old is this document ?

The biggest problem I have found with open source software is the abundance of undated out-of-date instruction with unstated assomptions or prerequisites. The learning curve is steep enough without deliberately making it harder.

By: jake