Posted by Steve on Mon 8 May 2006 at 07:21
Now that the Xen 3.0 packages have made it to Debians unstable distribution installation has become much more straightforward. Here we'll take a look at installing and getting started with it upon a generic unstable machine.
To start with we'll need to update our machine, so as root run:
Once you've got the most recent packages lists we can begin the work of installing the software properly. We'll need to install several packages:
Since the host I'm running upon has less than a gigabyte of memory I can use the normal Xen package. (Install xen-hypervisor-3.0-i386-pae if you need more memory.)
root@steve:~# apt-get install xen-hypervisor-3.0-i386 xen-utils-3.0
Once installed your next step depends on whether you're happy with the default kernel available in the Debian repository, or whether you'd like to install a kernel from scratch. I usually prefer using stock kernels, unless I need some specific hardware support that isn't available, so I'll just choose the default imag:
root@steve:~# apt-get install linux-image-2.6.16-1-xen-686Kernel Package Problem
The Xen kernel packages currently available in unstable don't create an initrd image when they are installed, so they fail to boot.
Create one by running the following command after installing the kernel:mkinitrd -o /boot/initrd.img-2.6.16-1-xen-686 2.6.16-1-xen-686
(Adjust the type from 686 if you're using a different flavour of the kernel such as k7)
Now that the kernel is installed and we have an initrd image we need to setup our bootloader to use it. Add something like the following to your /boot/grub/menu.lst file:
title Xen 3.0 / XenLinux 2.6 kernel /boot/xen-3.0-i386.gz noreboot module /boot/vmlinuz-2.6.16-1-xen-686 root=/dev/hda1 ro module /boot/initrd.img-2.6.16-1-xen-686
At this point you might wish to adjust the network settings that Xen will use. The xend daemon is configured via the file /etc/xen/xend-config.sxp, and this is commented pretty thoroughly.
For typical use the following are sufficient:
(network-script network-bridge) (vif-script vif-bridge)
Uncomment those lines and comment out any other settings for vif-script and network-script.
We should now be able to install the minor support tools and reboot into our new system. Get them by running:
root@steve:~# apt-get install bridge-utils iproute sysfsutils libc6-xen xen-tools
All being well a reboot now should succeed and allow you to boot into your Xen system. If you have problems consult any open bugs against the Debian packages, and if that doesn't give you joy please consider describing your problem upon the xen-users mailing list.
Assuming that you've got your new system booted correctly we can continue and create a new guest domain using the installed package xen-tools.
Create a directory to contain your guest files:
Now edit the file /etc/xen-tools/xen-tools.conf to match your setup:
# # /etc/xen-tools/xen-tools.conf # dir = /home/xen size = 2Gb memory = 128Mb swap = 128Mb fs = ext3 dist = sarge gateway = 192.168.1.1 netmask = 255.255.255.0 passwd = 1 initrd = /boot/initrd.img-2.6.16-1-xen-686 kernel = /boot/vmlinuz-2.6.16-1-xen-686 mirror = http://ftp.uk.debian.org/debian/
Here I've stripped out comments, but you should find sufficient explanation included in the file. The important things to setup are:
Once this is done you can create a new Xen guest image by executing the following command:
xen-create-image --hostname=test --ip=192.168.1.222 --passwd
Once the installation has finished, and you've been prompted to enter the new root password for the guest you can start the image by running:
xm create test.cfg -c
Press 'Ctrl+]' to exit from the console of the new system, and connect to it via SSH using the password specified when the image was created.
If you receive errors booting you might need to specify a ramdisk to the xen instance. Do that by editing the Xen configuration file /etc/xen/test.cfg and adding a line:
ramdisk = '/boot/initrd.img-2.6.16-1-xen-686'
The 1.4 release of xen-tools will do this for you automatically, however this might not have moved to sid yet.
Note: you don't need to use the xen-tools software to create new guest Xen domains. You can use debootstrap manually if you wish, or any other tools.