tested on 2015-05-01 on nemesis running debian 8.0
Terms used
dom0: the host machine running the hypervisor
domU: a virtual machine
We use lvm virtual disks because this method is faster then using file based storage. When setting up the host system, leave some disk space unused so we can build our Logical Volumes there. Assuming /dev/md3 is a virtual device representing the reserved disk space, we first build a virtual lvm device and then a volume group
pvcreate /dev/md3
vgcreate vg0 /dev/md3
That's it. The partitioning will be done automatically by xen-create-image.
apt-get install xen-linux-system-amd64 xen-tools
Grub must load the xen enabled kernel instead of the default one.
cd /etc/grub.d
mv 10_linux 25_linux
This is a virtual switch the domU uses to get network access.
edit /etc/network/interfaces in the following fashion:
# device: eth0
auto eth0
iface eth0 inet manual
auto xenbr0
iface xenbr0 inet static
bridge_ports eth0
address <dom0 ip>
broadcast 88.198.21.223
netmask 255.255.255.224
gateway 88.198.21.193
# default route to access subnet
# up route add -net 88.198.21.192 netmask 255.255.255.224 gw 88.198.21.193 eth0 <-- comment out this line
up route add -host <domU ip> gw <domU ip>
file /etc/sysctl.conf:
add:
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
edit:
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
run commands:
sysctl -p /etc/sysctl.conf
iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
xen-create-image --hostname=moros --memory=1G --vcpus=2 --lvm=vg0 --size=950G --swap=8G --fs=ext4 --ip=<domU ip> --netmask=255.255.255.192 --gateway=<dom0 ip> --install-method=debootstrap --dist=jessie --mirror=http://ftp2.de.debian.org/debian/ --passwd --pygrub --mac=00:50:56:00:80:08
--vg0: use the lvm we created in the first step
--size: size of the root partition
--swap: size of the swap partition
--fs: filesystem for root partition
--ip: the additional ip assigned by hetzner
--gateway: ip address of dom0
--pygrub: use a script that determines dom0's kernel version and instructs domU to use the same
--mac: virtual mac address assigned by hetzner
xl create -c /etc/xen/<hostname>.cfg
the console can be entered by xl console <hostname> and left by CTRL-]
other useful commands:
xl top: show stats for running machines
Sources
http://wiki.xen.org/wiki/Xen_Beginners_Guide
http://wiki.xenproject.org/wiki/Xen_Networking
http://wiki.xenproject.org/wiki/NetworkConfiguration_Examples%28Xen_4.1%2B%29
http://wiki.hetzner.de/index.php/Xenon_Debian_Lenny_using_the_additional_IPs%28EQ_Series%29
https://gist.github.com/meskyanichi/3354956
2015-01-05 mkl