If you have followed the guide in “Xen on Ubuntu Server 8.04 (Hardy Heron) with complex disk setup” or have an environment similar to that, please read on – if not please read on, too
. Since my server is hosted at Hetzner, this guide will be based on that. I want to use network bridging. To do that you need additional IP-addresses. My host has 213.x.x.6 and besides that I’ve got 78.x.x.1, 78.x.x.2, …, 78.x.x.6 (plus a broadcasting address).On my host I’ve got this:
root@host:~# cat /etc/network/interfaces ### Hetzner Online AG - installimage # Loopback device: auto lo iface lo inet loopback # device: eth0 auto eth0 iface eth0 inet static address 213.x.x.6 broadcast 213.x.x.31 netmask 255.255.255.224 gateway 213.x.x.1 # default route to access subnet up route add -net 213.x.x.0 netmask 255.255.255.224 gw 213.x.x.1 eth0 auto eth0:1 iface eth0:1 inet static address 78.x.x.1 broadcast 78.x.x.7 netmask 255.255.255.248
The plan is that the guests will get 78.x.x.2, 78.x.x.3, etc. and will use 78.x.x.1 as gateway (you’ll see this later) – that’s why I’ve assigned it to the host.
Well, after you have found out that Xen kernel is loaded with
uname -r xm list
you’ll be ready to proceed.
Now we want to make a domU with Ubuntu Server 8.04 with the program debootstrap. First identify the partitions you want to use. For the root filesystem I’ll use /dev/lvmstore/lv1 and for swap I’ll use /dev/sda6. To prepare the partitions, please
mkfs.xfs /dev/lvmstore/lv1 mkswap /dev/sda6
Now it’s time to install the guest system. First mount the root file system like this:
mount /dev/lvmstore/lv1 /mnt
Now just install it with this simple command (depending on your environment you might have to change the --arch-parameter):
debootstrap --arch amd64 hardy /mnt http://archive.ubuntu.com/ubuntu
Now you should copy a couple of files:
cp /etc/resolv.conf /mnt/etc/resolv.conf cp /etc/apt/sources.list /mnt/etc/apt/sources.list mkdir /mnt/lib/modules/`uname -r` cp -R /lib/modules/`uname -r`/* /mnt/lib/modules/`uname -r`/
Now you should change a couple of files. Now
vi /mnt/etc/network/interfaces
should have the content
root@host:~# cat /mnt/etc/network/interfaces auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 78.x.x.2 broadcast 78.x.x.7 netmask 255.255.255.248 gateway 78.x.x.1
Here you see that I’m using the host as gateway.
And
vi /mnt/etc/hostname
to change the hostname of the guest.
We also need to change the fstab – mine looks like this (remember to change xfs to ext3 or similar if you’re not using xfs):
root@host:~# cat /mnt/etc/fstab /dev/sda1 / xfs defaults 1 2 /dev/sda2 none swap sw 0 0
The names /dev/sda1 and /dev/sda2 is assigned on a Xen configuration file we’ll get to that i a minute.
Now we prepare the network bridge at the host by:
vi /etc/sysctl.conf
and change
#net.ipv4.ip_forward=1to
net.ipv4.ip_forward=1We also start the network bridge:
/etc/xen/scripts/network-bridge start
Now reboot the host to enable the changes in /etc/sysctl.conf. After reboot please check that the bridge is okay:
brctl show
Now we create the file /etc/xen/domU1.conf with this content:
root@host:~# cat /etc/xen/domu1.cfg kernel = '/boot/vmlinuz-2.6.24-19-xen' ramdisk = '/boot/initrd.img-2.6.24-19-xen' memory = '512' maxmem = '1536' root = '/dev/sda1 ro' disk = ['phy:/dev/lvmstore/lv1,sda1,w','phy:/dev/sda6,sda2,w'] name = 'domU1' vif = ['bridge=eth0'] on_poweroff = 'destroy' on_reboot = 'restart' on_crash = 'restart' vcpus = '2' extra = 'xencons=tty1'
This is the specs of the guest. This is a configuration making you able to ballon the amount of memory to 1,5 GB instead of the initial 512 MB. Please view man xmdomain.cfg for further details.
Now start the guest (the -c means that the console is attached to the guest immediately):
xm create /etc/xen/domu1.cfg -c
When the environment is started, login with the same password as on your host. Now check the network is okay, change the password, and update the system, respectively:
ping 78.x.x.1 passwd apt-get update apt-get upgrade apt-get dist-upgrade
You’ll probably see some locales errors. For my case (da_DK) it’s fixed by this:
locale-gen da_DK.UTF8 tzselect echo "export LANG=C" >> ~/.bashrc
Please refer to https://wiki.ubuntu.com/DebootstrapChroot for details regarding this and debootstrap in general.
To shut it down, use
init 0You can start the guest without the -c-parameter to start it without the console. Then you can use
xm list
to check that it’s running.
At this point I’d strongly recommend to shut the guest down, reboot the host (dom0) and start everything again. This is to verify that everything is also working after a reboot (before using it in production).
I followed http://www.howtoforge.com/high-performance-xen-on-ubuntu-8.04-amd64 when I installed the guest, but I’ve done it slightly different and avoided some of the errors.

September 16th, 2008 at 15:30 (UTC)
By the way – you might want a SSH-server:
apt-get install openssh-server
/etc/init.d/ssh start
September 16th, 2008 at 16:27 (UTC)
Actually the /etc/network/interfaces needs to have the loopback device included, too:
auto lo
iface lo inet loopback
Or else you might run into trouble, e.g. with MySQL.
November 13th, 2008 at 13:57 (UTC)
I finally got this working but i’m experiencing lots of packetloss to my guests. In my search i noticed that you’re not allowed to use bridging on the Hetzner setup, but have to use routed xen setup. I’ll try this tonight, maybe you can add it to your very good tutorial
November 13th, 2008 at 17:25 (UTC)
Thanks for your comment, Karel. I haven’t noticed any severe packetloss, but you’re advice is hereby passed on.
January 19th, 2010 at 21:40 (UTC)
[...] Ubuntu 8.04 LTS as a domU on the above setup [...]