Installing Xen On An Ubuntu 8.04 (Hardy Heron) Server From The Ubuntu Repositories

Version 1.0
Author: Falko Timme

This tutorial provides step-by-step instructions on how to install Xen on an Ubuntu Hardy Heron (Ubuntu 8.04) server system (i386). You can find all the software used here in the Ubuntu repositories, so no external files (apart from a fixed Ubuntu Xen kernel to enable networking for the virtual machines) or compilation are needed.

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 Ubuntu Hardy Heron (i386) for the host OS (dom0) and Ubuntu Hardy Heron and Ubuntu Gutsy Gibbon (7.10) for the guest operating systems (domU). Other Debian-based distributions that can be installed using xen-tools are Debian Etch, Debian Lenny, Debian Sid, and Debian Sarge, as well as Ubuntu Dapper Drake, Ubuntu Edgy Eft, and Ubuntu Feisty Fawn.

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 Ubuntu Hardy Heron Host System (dom0)

You can install the host system (dom0) as shown in the chapters one to ten of this tutorial: (of course, you don't have to do this if you already have an Ubuntu 8.04 host system that you want to use).

Make sure that you are logged in as root (type in

sudo su

to become root), because we must run all the steps from this tutorial as root user. Also, if you want to use vi as your text editor (as suggested by this tutorial), you should run

apt-get install vim-full

The vim-full package makes sure that the vi text editor behaves as expected (without vim-full, you might experience some strange behaviour in the vi text editor).

It's a good idea to disable AppArmor:

/etc/init.d/apparmor stop
update-rc.d -f apparmor remove

dom0's FQDN in this example will be's IP address will be in this tutorial, and the gateway I use is, so the virtual machines will have to use that one, too.


2 Install Xen

To install Xen and all needed dependencies, all we have to do is run the following command:

apt-get install ubuntu-xen-server

This will also install the xen-tools package which we use later on to create virtual machines.

The ubuntu-xen-server package installs the Ubuntu kernel 2.6.24-16-xen; unfortunately there's a nasty bug in this kernel which causes networking to not work for virtual machines (see and Fortunately Hirano Takahito has patched this kernel and made the patched versions (for i386 and amd64) available on (I have created a mirror of these packages at in case the original link doesn't work anymore one day). Download the correct linux-image package for your architecture (i386 or amd64), e.g.:


Then replace the Ubuntu 2.6.24-16-xen kernel with it like this:

dpkg -i linux-image-2.6.24-16-xen_2.6.24-16.30zng1_i386.deb  

Next do this:

mv /lib/tls /lib/tls.disabled 

We also need to add the loop module to the kernel every time we boot our system, so we edit /etc/modules. If you already have a loop line in there, make it look like this, otherwise add it:

vi /etc/modules
loop max_loop=64

Now take a look at the /boot directory to see which kernels and ramdisks are installed:

ls -l /boot/

[email protected]:~# ls -l /boot/
total 34380
-rw-r--r-- 1 root root  426444 2008-04-10 18:55 abi-2.6.24-16-server
-rw-r--r-- 1 root root   80203 2008-04-10 18:55 config-2.6.24-16-server
-rw-r--r-- 1 root root   85149 2008-04-19 23:17 config-2.6.24-16-xen
drwxr-xr-x 2 root root    4096 2008-05-06 15:19 grub
-rw-r--r-- 1 root root 7323503 2008-04-24 11:47 initrd.img-2.6.24-16-server
-rw-r--r-- 1 root root 7047843 2008-04-24 11:45 initrd.img-2.6.24-16-server.bak
-rw-r--r-- 1 root root 7056979 2008-05-06 15:19 initrd.img-2.6.24-16-xen
-rw-r--r-- 1 root root 7062168 2008-05-06 15:09 initrd.img-2.6.24-16-xen.bak
-rw-r--r-- 1 root root  103204 2007-09-28 12:06 memtest86+.bin
-rw-r--r-- 1 root root  933296 2008-04-10 18:55
-rw-r--r-- 1 root root  883544 2008-04-19 23:17
-rw-r--r-- 1 root root 1987288 2008-04-10 18:55 vmlinuz-2.6.24-16-server
-rw-r--r-- 1 root root 1730344 2008-04-19 23:17 vmlinuz-2.6.24-16-xen
-rw-r--r-- 1 root root  370610 2008-04-11 03:16 xen-3.2.gz
[email protected]:~#

The /boot/vmlinuz-2.6.24-16-xen kernel is the new, patched Xen kernel, and /boot/initrd.img-2.6.24-16-xen is its ramdisk. We will need these soon.

You can now also take a look at the /usr/lib/xen-tools directory because it reveals which distributions can be installed in a virtual machine with xen-tools:

ls -l /usr/lib/xen-tools

[email protected]:~# ls -l /usr/lib/xen-tools
total 36
drwxr-xr-x 2 root root 4096 2008-05-06 15:08 centos-4.d
drwxr-xr-x 2 root root 4096 2008-05-06 15:08 centos-5.d
-rwxr-xr-x 1 root root 4409 2008-04-06 03:12
drwxr-xr-x 2 root root 4096 2008-05-06 15:08 dapper.d
drwxr-xr-x 2 root root 4096 2008-05-06 15:08 debian.d
drwxr-xr-x 2 root root 4096 2008-05-06 15:08 edgy.d
lrwxrwxrwx 1 root root    8 2008-05-06 15:08 etch.d -> debian.d
lrwxrwxrwx 1 root root   15 2008-05-06 15:08 fedora-core-4.d -> fedora-core-6.d
lrwxrwxrwx 1 root root   15 2008-05-06 15:08 fedora-core-5.d -> fedora-core-6.d
drwxr-xr-x 2 root root 4096 2008-05-06 15:08 fedora-core-6.d
lrwxrwxrwx 1 root root   15 2008-05-06 15:08 fedora-core-7.d -> fedora-core-6.d
lrwxrwxrwx 1 root root    6 2008-05-06 15:08 feisty.d -> edgy.d
drwxr-xr-x 2 root root 4096 2008-05-06 15:08 gentoo.d
lrwxrwxrwx 1 root root    6 2008-05-06 15:08 gutsy.d -> edgy.d
lrwxrwxrwx 1 root root    6 2008-05-06 15:08 hardy.d -> edgy.d
lrwxrwxrwx 1 root root    8 2008-05-06 15:08 lenny.d -> debian.d
lrwxrwxrwx 1 root root    8 2008-05-06 15:08 sarge.d -> debian.d
lrwxrwxrwx 1 root root    8 2008-05-06 15:08 sid.d -> debian.d
[email protected]:~#

As you see we can install the following distributions:

  • Debian: Etch, Lenny (testing), Sid (unstable), Sarge
  • Ubuntu: Dapper Drake, Edgy Eft, Feisty Fawn, Gutsy Gibbon, Hardy Heron
  • CentOS 4, CentOS 5
  • Fedora Core 4, 5, 6, Fedora 7
  • Gentoo

(I haven't tried to install CentOS, Fedora, and Gentoo with xen-tools yet, so I can't say how good it works.)

I want to store my virtual machines in the /home/xen directory, therefore I create it now:

mkdir /home/xen

We will use xen-tools to create virtual machines. xen-tools make it very easy to create virtual machines - please read this tutorial to learn more: As mentioned before, the xen-tools package got installed together with the ubuntu-xen-server package.

Now 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:

vi /etc/xen-tools/xen-tools.conf
dir = /home/xen
dist   = hardy     # Default distribution to install.
gateway   =
netmask   =
broadcast =
passwd = 1
mirror =

The dist line holds the default distribution that you want to install in a virtual machine. The contents of the /usr/lib/xen-tools directory reveals which distributions are available (see above).

The kernel line must contain our Xen kernel, and the initrd line its ramdisk. The default /etc/xen-tools/xen-tools.conf file has the values kernel = /boot/vmlinuz-`uname -r` and initrd = /boot/initrd.img-`uname -r` which automatically translate to the correct kernel and ramdisk, so we don't have to modify these lines.

The passwd = 1 line makes that you can specify a root password when you create a new guest domain. In the mirror line specify an Ubuntu 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 reboot the system:


If your system reboots without problems, then everything is fine!


uname -r

and your new Xen kernel should show up:

[email protected]:~# uname -r
[email protected]:~#

Share this page:

Suggested articles

12 Comment(s)

Add comment



It's not necessary to download the separate package any more.  There is a package in the hardy-proposed repository that works.

To use this package

echo "deb hardy-proposed main universe" >> /etc/apt/sources.list
apt-get update
aptitude install linux-image-2.6.24-17-xen


This is no longer required - the updated kernel modules have been moved to the main repositories.

All that is required is to install ubuntu-xen-server, then move on to "vi /etc/modules"

Note that I found the "mv /lib/tls /lib/tls.disabled" step redundant, as the /lib/tls directory is not present (AMD64 installation).

Thanks for a great guide!

By: Hety

I have issues with netwoking on machine with Xen kernel. WHile i can ping and access everything normally on LAN it cant go out to Internet for some reason.

 here is ifconfig output

eth0      Link encap:Ethernet  HWaddr 00:30:48:66:02:3c
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::230:48ff:fe66:23c/64 Scope:Link
          RX packets:715 errors:0 dropped:0 overruns:0 frame:0
          TX packets:206 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:114008 (111.3 KB)  TX bytes:28333 (27.6 KB)


peth0     Link encap:Ethernet  HWaddr 00:30:48:66:02:3c
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::230:48ff:fe66:23c/64 Scope:Link
          RX packets:761 errors:0 dropped:0 overruns:0 frame:0
          TX packets:239 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:150448 (146.9 KB)  TX bytes:34463 (33.6 KB)
          Base address:0x2000 Memory:d8020000-d8040000


And thats what ping says:

for local machine

[email protected]:~$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=128 time=0.177 ms
64 bytes from icmp_seq=2 ttl=128 time=0.090 ms

--- ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.090/0.133/0.177/0.045 ms

for smth on Internet:

 [email protected]:~$ ping
PING ( 56(84) bytes of data.
From ubuntu-host.local ( icmp_seq=2 Destination Host Unreachable
From ubuntu-host.local ( icmp_seq=3 Destination Host Unreachable
From ubuntu-host.local ( icmp_seq=4 Destination Host Unreachable

--- ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3999ms
, pipe 3


Ideas? When i switch back to reguar kernel it all works fine. Network is DHCP enabled.



By: poly

I have the exact same problem.  Has anyone found a fix for this yet?


I had similar problem. It was routing basically. You need to configure eth0 as usual, and peth0 should be up but excluded from routing (if you use DHCP it would make it included in routing). One of simplest ways to achieve it is to set peth0 as ipv4ll.

By: Jiang

Hi grw:

Would you please give some details about how to config eth0 and peth0? Such as instructions or examples? I am new to Linux network and Xen.



By: a_lawry

Remove the network-manager package. apt-get remove network-manager

By: KFCSpike

I had the same problem and eventually found it was my iptables in dom0 that was the problem...

<code> #I think we have an iptables problem, so first of all write out the old table.
iptables-save > /etc/iptables.check.this
nano /etc/iptables.check.this</code>

 If there is a line in there that looks like...

<code>-A FORWARD -j REJECT --reject-with icmp-port-unreachable</code>

then remove it, save the file, and load it into iptables using...

<code>iptables-restore < /etc/iptables.check.this</code>

If this clears it you may want to save this to your boot-up iptables, on my system I used...

<code>iptables-save > /etc/iptables.up.rules</code>




Ok guys i found an easy way around for my previous post!

The bug is actualy in the xen-tools config file! When you edit it just make sure that you edit the line saing 'reiser_options=defaults' to 'reiserfs_options=defaults' in /etc/xen-tools/xen-tools.conf. That will set the proper options in the fstab of the VMachine.

You can change 'defaults' to whatever options for reiserfs you like. In my case 'notail,relatime' works fine!!


First excuse my poor english!
Because this site is greate i yould like to contribute with my research to!
I tried to install Xen on Ubuntu 8.04 and to create VMachine with Ubuntu 8.04 using reiserfs. I follow the how to and changed the fs=ext3 line in /etc/xen-tools/xen-tools.conf with fs=reiserfs. Everything well smooth as i follow the tutorial only to see at the end that my new VM was not booting correctly! The error was that the file system on the VM was read-only! I tried everything again with ext3, thinking that you may provide bad tutorial but it was ok. With ext3 the VM's file system loaded as read-write and I was able to work with it properly. Then I decided to try again because I like Reiser FS more and I saw the option 'reiser_options = defaults' in /etc/xen-tools/xen-tools.conf and change it from default to 'notail,relatime' as i saw this in my /etc/fstab. Unfortunately the outcome was the same - still no read-only FS. I still manage to log on to my VM though and saw in the VM's /etc/fstab that the options for the file system were according to ext3 FS (noatime,nodiratime,errors=remount-ro). So the work arround was before creation of the VM to mount the created disk img - /etc/home/xen/domains/ with 'mount -o loop /etc/home/xen/domains/ /mnt'. Then i edit the fstab in the mounted file system with 'vi /mnt/etc/fstab' and set the corect options for reiserfs (notail,relatime). Created the VM with 'xen-create-image' and everything well just fine!

By: teknophile

I'm using ubuntu 10.04 64-bit.

when I try 'apt-get install ubuntu-xen-server' I get the following error:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
  ubuntu-xen-server: Depends: xen-tools but it is not installable
E: Broken packages

If xen-tools isn't installable then is this how-to out of date?

By: Anonymous

Excuse me. when I installed xen kernel and rebooted the system I chose it from grub menu list and it seemed it was working but after writing some output on screen, I did not see anything on screen and it was kind of crash. The computer did not respond to any other key and I had to reset it. what is the problem. I have Linux 8.1