This is supersceeded by my install on Debian Squeeze). On Lenny, everything is just too outdated.
This will explain how to install the paravirtualization software Xen on Debian. It is more involved than KVM, but more elegant if you can setup up a dedicated machine to run virtual machines (in fact, KVM on Debian seems quite clunky). I use this Debian wiki page as base.
First some terminology. On Xen, everything runs virtualised, including what in KVM would be called the “Host OS”. This is because every OS instance shares some kernel space. Xen has a primary virtual machine with which you configure the other virtual machines. This is called Domain-0, or Dom0. The guests are DomU’s.
Begin by installing xen-linux-system-2.6.26-2-xen-686 and xen-tools. It will install all necessary dependencies:
aptitude -P install xen-hypervisor-3.2-1-i386 linux-image-2.6-xen-686 xen-tools
(The wiki page suggests to install linux-image-2.6.26-2-xen-686, but that confuses me. See my forum post. I will update this blogpost if my insights change).
A new kernel is installed and is configured in Grub as primary kernel. (As a sidenote, I wonder what will happen if the standard kernel is upgraded at some point in the future; will that be installed as primary again? Should the standard kernel be uninstalled?)
Before you reboot, add “xenblktap” to /etc/modules. This module is needed to be able to use tap:xxx (like tap:aio) storage back-ends. These are preferred over “file:”, especially when using NFS to store images (although that link also states that ENBD is preferred over NFS. (I was having problems with tap:aio and then I discovered the module problem. It still doesn’t work for me, but the problem lies elsewhere now.)
If you boot into the new kernel you can do “xm list” and you will see that your Domain-0 is active.
You want to setup an ethernet bridge configuration next, because that way, you can plug your virtual machines into your existing ethernet network. You can do this by configuring this in the config file /etc/xend-config.xsp (The network-script option is already defined, so all you have to do is change it):
Configuring “vnc-listen” might also be a good idea (although not really needed for linux, since you’ll be using the xen console). Setting it to localhost and then tunnling through SSH would be the safest, obviously.
Now it’s time to add DomU’s. Because the guests need to have DomU support, the OS cannot be installed with the normal installer (although I’m not sure this is still the case for Lenny, because the Wiki says: “In Lenny the distinction between the Xen and non-Xen flavours of the kernel (with respect to domU support) is no longer present.”).
First edit /etc/xen-tools/xen-tools.conf to set some good defaults. You can remove the noatime mount options for ext2 and ext3, for example. I can also set the default mirror to “http://ftp.nl.debian.org/debian/”.
xen-create-image --hostname=virtualnode --size=2Gb --dist=lenny --memory=256M --dhcp --dir /root/xen-images/ --swap 256Mb
You have to mount the image to make some corrections. In my case, the image was still mounted somewhere in /tmp. I assume this is bug. Begin by editing /etc/inittab. Comment out the existing “1:…” tty and add the line :
1:2345:respawn:/sbin/getty 38400 hvc0
to /etc/inittab, otherwise your console won’t work.
Start the virtual machine and attach a console (the -c option) like this:
xm create -c virtualnode.cfg
One of the first things you want to install is udev, because you can’t even ssh to the box without it.
The resulting Debian installation is very bare; it doesn’t even have a mail infrastructure.
On the Dom0, you can mkdir /etc/xen/auto and symlink the config file for this virtual host there to have it auto started by the xendomains bootscript.