Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

Hetzner and Xen

carlio edited this page Mar 19, 2014 · 8 revisions

This page has instructions on how to set up a Hetzner server to run Xen, and how to create virtual machines once it is running.

General Hetzner Setup

ACPI

There is a bug which sometimes occurs which prevents a server from restarting. Advice from the Hetzner support staff is to use acpi=ht in the boot command. Edit /etc/default/grub and ensure that the GRUB_CMDLINE_LINUX_DEFAULT value includes acpi=ht.

Install Xen

This mostly came from http://clarkdave.net/2012/11/setting-up-ubuntu-12-04-and-xen-on-hetzner/ but has some important differences.

apt-get update
apt-get install xen-hypervisor-amd64 xen-tools

Edit /etc/grub/default and change:

GRUB_DEFAULT="Xen 4.1-amd64"

And edit /etc/default/xen to contain this line:

TOOLSTACK="xm"

Allow use of many loopback interfaces - edit /etc/modules to include:

loop max_loop=255

Update grub and reboot:

update-grub
reboot

Setup Networking

Open up /etc/sysctl.conf and update it so it has the following settings:

net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.default.proxy_arp=1
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv6.conf.all.forwarding = 1

Now open /etc/xen/xend-config.sxp and ensure that these lines are commented out:

(network-script network-bridge)
(vif-script vif-bridge)

and also ensure that these lines are present and are not commented out:

(network-script network-route)
(vif-script     vif-route)

This will let Xen know we’re routing, not bridging, network traffic. Now open up /etc/network/interfaces and comment out the up route add line, e.g:

#up route add -net 5.9.119.52 netmask 255.255.255.224 gw 5.9.119.51 eth0

Configure Guest Defaults

Copy the contents of this page into /etc/xen-tools/xen-tools.conf - https://github.com/akvo/akvo-provisioning/wiki/xen-tools.conf . Note you will have to replace the IP and netmask.

Create a directory for the guest images:

mkdir /xen

And enable creating guests using Ubuntu 12.04

cd /usr/lib/xen-tools
cp -r lucid.d precise.d

Create a Guest (domU)

First create the image. You can use additional options here, if you want to override settings in xen-tools.conf.

xen-create-image --hostname=<hostname> --ip=<IP address>

At the end, you will see a root password. Keep that handy. The image will boot automatically. Connect using

xm console <hostname>

Log in using root and the above password, then change the password immediately.

Next, networking needs to be fixed. Edit /etc/network/interfaces and add this line to eth0:

pointopoint <same_ip_as_gateway>

Note: the only editor installed by default is vi. If you're not familiar with it, simply use the following keystrokes:

/gate <Enter>
yypcw
pointopoint
<Esc>:wq

Restart networking:

/etc/init.d/networking restart

Tada! You should probably apt-get update and apt-get upgrade at this point.