Xen is usually my go to virtualization technology for Linux. Here’s a HOWTO on setting up Xen on Debian Wheezy and the first guest virtual machine.

First step is getting the required packages:

apt-get install xen-linux-system xen-tools xen-utils-4.1 xen-utils-common xenstore-utils xenwatch

Now, we’ll need to specify the Xen kernel as the default boot kernel on the host, and then reboot:

dpkg-divert --divert /etc/grub.d/08_linux_xen --rename /etc/grub.d/20_linux_xen


On rebooting, ensure that your new Xen kernel is active:

xm info


Now, Xen supports bridged, routed and host only network setups. As I host with Hetzner, they provide a routed block – no default gateway provided. In my case, I needed to edit /etc/xen/xend-config.sxp to comment:

#(vif-script vif-bridge)


And uncomment:

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

I also needed to assign my eth0:0 interface the second IP on the subnet my ISP provided (the first being the unusable network address).

Now edit /etc/sysctl.conf to enable IP forwarding and other required settings:

net.ipv6.conf.all.forwarding = 1

And reload sysctl and Xen with:

sysctl -p
/etc/init.d/xen restart

Next, to build the first virtual machine:

mkdir /vm
xen-create-image --hostname=vm1.iodigitalsec.com --ip=YOUR_VM_IP --netmask=YOUR_VM_NETMASK --gateway=YOUR_VM_GATEWAY --pygrub --dist=wheezy --memory=2048M --vcpus=2 --dir=/vm --size=120Gb --swap=4Gb

In my case, ‘YOUR_VM_GATEWAY’ was the address I bound to eth0:0 above. I’ve chosen to use flat image files and create them under /vm. Your virtual machine disk files can also be created on a dedicated partition, or using LVM for easier future management.

Once the setup script has completed, start the new virtual machine with:

xm create vm1.iodigitalsec.com.cfg