XEN On An Ubuntu Hardy Heron (8.04) Server System (amd64) - High Performance

This tutorial provides step-by-step instructions on how to install XEN on an Ubuntu Hardy Heron (8.04)  Server System (amd64) without compromising on disk I/O and network throughput. You can find all the software used here in the Ubuntu repositories, so no external files or source compilation are required.

Xen is an open-source para-virtualizing virtual machine monitor (VMM), or 'hypervisor', for the x86 processor architecture. Xen can securely execute multiple virtual machines on a single physical system with close-to-native performance. Xen facilitates enterprise-grade functionality, including:

  • Virtual machines with performance close to native hardware.
  • Live migration of running virtual machines between physical hosts.
  • Up to 32 virtual CPUs per guest virtual machine, with VCPU hotplug.
  • x86/32, x86/32 with PAE, and x86/64 platform support.
  • Intel Virtualization Technology (VT-x) for unmodified guest operating systems (including Microsoft Windows).
  • AMD Virtualization Technology (SVM aka Pacifica) on AM2 and F stepping Opterons (2006H2)
  • Excellent hardware support (supports almost all Linux device drivers).


1. Partition And Primary OS Installation

I will use Ubuntu Hardy Heron (x86_64) for both the host OS (dom0) and the guest operating systems (domU). Prior to this you should have a target system ready with partitions like in the following example:

For example we have 120GB disk space and we want to use 2 guest operating systems on it:

  • Take as minimal as required for host OS (dom0), say 10-12GB => so create the first partition accordingly.
  • We will divide the rest of the free space in 2 partitions, each for 2 guest OS's (domU's) => so create the next two partitions accordingly.

Install the Ubuntu Hardy Heron (x86_64) Server Edition (http://www.ubuntu.com/products/whatisubuntu/serveredition) on the first partition only. Afterwards, on this we will be install the Xen stuff and use this as the host OS (dom0). As per better practice, dom0 should not be used for any production use except for controlling guest OS's. So only choose "ssh" in package selection during OS installation.

After the OS installation the first job is to update/upgrade the OS. Login to the system as root and type following commands:

# apt-get update
# apt-get upgrade


2. Host OS And Xen Installation

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

# apt-get install ubuntu-xen-server

The ubuntu-xen-server package installs the Ubuntu kernel 2.6.24-17-xen and other dependent xen packages.

Also upgrade the vi editor as follows:

# apt-get install vim 

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 at the bottom of the file: 

# vi /etc/modules 
loop max_loop=64

That's all. Now reboot the system. And after the reboot check the OS and xen service as follows:

# uname -a
# xm list


3 Creating Filesystem For Guest OS (domU)

For the creation of domU we will be using "debootstrap". Here we will be using direct physical disk partitions and no filesystem images for better disk I/O for the guest OS. So format the partition for your filesystem choice. If you are interested in the xfs filesystem then you must install the "xfsprogs" package on dom0 like this:

# apt-get install xfsprogs

To create a filesystem on the second partition we use the following command:

If you are choosing ext3 then:

# mkfs.ext3 /dev/sda2

If you are choosing  xfs then:

# mkfs.xfs /dev/sda2 

Post creation of filesystem in target partition mount it to /mnt:

# mount /dev/sda2 /mnt 


4. Installing The Guest OS

Install the base OS stuff in /mnt using "debootstrap":

# debootstrap --arch amd64 hardy /mnt http://archive.ubuntu.com/ubuntu

This is going to take sometime depending on your Internet connection speed.

Once done, prepare the chroot environment for /mnt:

# mount --bind /dev /mnt/dev
# mount proc /mnt/proc -t proc
# chroot /mnt /bin/bash 

Open another terminal and copy a couple of files from dom0 to /mnt's respective folder:

# cp /etc/resolv.conf /mnt/etc/resolv.conf
# cp /etc/network/interface /mnt/etc/network/interface
# cp /etc/apt/source.list /mnt/etc/apt/sources.list
# cp -R /lib/modules/2.6.24-17-xen/* /mnt/lib/modules/2.6.24-17-xen/

(If the respective folder is not present, then please create it before copying.)

Now again from the domU chroot environment use the following commands:

# apt-get update
# apt-get upgrade
# apt-get install vim ssh

If you are using the xfs filesystem then also install xfsprogs as follows:

# apt-get install xfsprogs 
Update /etc/fstab as follows:

If you are using the ext3 filesystem then:

/dev/hda1               /               ext3	defaults        1       2

If you are using the xfs filesystem then:

/dev/hda1               /               xfs	defaults        1       2

This is the minimal setup of the domU environment. Not set the root password as:

# passwd

It's going to prompt you for root's password, so provide some secret for it.

Now exit from the chroot environment:

# exit

Now umount all partitions:

# umount  /mnt/dev /mnt/proc /mnt


5. Creation Of Xen Config File

Now create the first guest OS's xen config file named domu1.cfg in the /etc/xen/ folder like this:

vi /etc/xen/domu1.cfg 
kernel      = '/boot/vmlinuz-2.6.24-17-xen'
ramdisk     = '/boot/initrd.img-2.6.24-17-xen'
memory      = '512'
#  Disk device(s).
root        = '/dev/hda1 ro'
disk        = [
#  Hostname
name        = 'domu1'
#  Networking
vif         = [ 'ip=,mac=00:16:3E:62:DA:BB' ]
#  Behaviour
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'
vcpus	    = '2'
extra = 'xencons=tty1'

You must use a free and different IP for each guest OS.

Then start the first domU like this:

# xm create /etc/xen/domu1.cfg -c

Log in using root and that's all... your first guest OS (domu1) is ready now.

In dom0, to list running OS's, type:

# xm list 

The steps to create second virtual system on /dev/sda3 are similar...

The same steps can be followed for i386 also...


Share this page:

Suggested articles

8 Comment(s)

Add comment




Thanks for this great article, it's simple and efficient but I have some corrections and advices.

I would have done the:

# chroot /mnt /bin/bash

After these 4 commands (so I don't need to open an another terminal:

# cp /etc/resolv.conf /mnt/etc/resolv.conf

# cp /etc/network/interface /mnt/network/interface

# cp /etc/apt/source.list /mnt/etc/apt/sources.list

# cp -R /lib/modules/2.6.24-17-xen/* /mnt/lib/modules/2.6.24-17-xen/

Also, there are some typos (/etc/network/interface should be /etc/network/interfaces with a final s, /etc/apt/source.list should be /etc/network/sourceS.list)

The commands I typed looked like this:

# cp /etc/resolv.conf /mnt/etc
# cp /etc/network/interfaces /mnt/etc/network
# cp /etc/apt/sources.list /mnt/etc/apt

Also to copy the modules I used:

# mkdir /mnt/lib/modules/`uname -r`
# cp -R /lib/modules/`uname -r`/* /mnt/lib/modules/`uname -r`/

 Instead of :

# cp -R /lib/modules/2.6.24-17-xen/* /mnt/lib/modules/2.6.24-17-xen/

 I'm wondering if after the chroot and apt-get update, when we are doing "apt-get upgrade" we aren't supposed to do an "apt-get dist-upgrade" , but the result is seems to be the same.

Finally, for the root filesystem of my vm, I haven't used a physical partition, I've used a file on my dom0's filesystem.

To do so, I have executed the following commands:

# mkdir /home/xen ; cd /home/xen

# dd if=/dev/zero of=hardyvm.root bs=10M count=100
# mkfs.ext3 hardyvm.root
# mount -o loop hardyvm.root /mnt/

This dd command creates a 1Gig file with no data.

Then in "/etc/xen/domu1.cfg" I have that line:

disk        = ['tap:aio:/home/xen/hardyvm.root,hda1,w',]

 Note the 'tap:aio:/home/xen/hardyvm.root' instead of 'phy:/dev/sda2,hda1'

Otherwise , this tutorial is great, simple and straightforward !

Thank you very much !



 Nice to see corrections from you.

 But still think, one should use "phy:" than "tap:"  as writing on physical disk is quite faster than writing on image-file. I already have experienced the same many a times on production environments.


By: Anonymous

I dont have an AMD64 based computer.. what am I to do?

I get a series of error even before that!

like is xen running?

/mnt is empty?!

xen is not in my menu.lst file and is not loading at the boot up?!

I manually downloaded xen3.3.0.tar.gz and expanded it in to /xen3xyz  folder but i get a bunch of errors when i do ./install.sh!?

i moved it around still the same error...




Hi, I followed the howto, I was able to successfully start the domu1 virtual machine but I ran into problems.

First, networking doesnt work :( I can see eth0 but it has no ip address.

Second, when I type df -h I dont see /dev/hda1. Is that normal?

I tried Falko howto (with image file), networking was working and I could see the "partition" doing df -h but I would prefer to write directly on a partition instead of an image file. Did some quick benchmark with his method, drive performance using an image file was around 50% of the native drive performance which is quite bad....

 Also is there anything special I need to put in the domain config file with a dual cpu machine? I have dual (2x)  xeon 5140 processor (dual core) with HT enabled. How many VCPU i have available? 4, 8?

thanks for your help!



Hi Marc,

Problem: First, networking doesn't work :( I can see eth0 but it has no ip address.

Ans:  You need to asign IP to domU either in /etc/network/interfaces or through /etc/xen/domu1.cfg file.


Problem: Second, when I type df -h I dont see /dev/hda1. Is that normal?

Ans: Yes it's normal. This is because we have define /dev/hda1 in /etc/fstab file of domU(s). You can spesify /dev/sda1 as well. But don't forget to change /etc/xen/domu1.cfg file accordingly.

-- Hope this clears your doubts.


By: Anonymous

This is really a great tutorial.

I do however have the following questions:

  1. I have 5 public addresses for the physical server and I would like to use one of them for domu1 and another one for domu2. Is this possible or should I other IPs
  2. how can I install on domu2 another OS like windows or any non linux OS

Thank you

By: Boris

This posting deals with utilizing same image device for loading HVM and PV Ubuntu Hardy DomUs at Ubuntu Hardy Dom0 (2.6.24-21-xen #1 SMP Mon Aug 25 18:56:44 UTC 2008 x86_64 GNU/Linux). This approach allows to avoid traditional "debootstrap" procedure as well as taking a long time "apt-get install ubuntu_desktop", what is, actually, 400 MB download. It also provides a workaround to get Gnome Desktop working stable at Ubuntu PV DomU no matter on Xen Release (>=3.1.2) and OS (Solaris,Linux) running at Dom0. Install Ubuntu Hardy HVM DomU via hvm-profile.


By: Jahn

Would be very interesting if there were a tutorial on how to install a Windows Guest on Ubuntu Xen!