Xen from Backports on Debian Sarge
Posted by Aike on Fri 21 Jul 2006 at 15:38
There is a great howto about installing Xen on Debian Unstable. It is really easy to do and it runs fine. Nevertheless, on production servers, that's not an optimal solution. Debian Unstable has too many updates and things change too often. On production machines, a Xen host system should be stable, secure and should not need much attention. That is where Sarge comes in. If you pull the Xen packages from backports and install them on Debian stable you've got the best of both worlds. Let's do so!
Before you start with this howto, you need to find yourself some hardware and install Sarge the way you like it. I used a Sun Fire X2100 with 4GB of ram and 2 SATA disks in software raid1.
Add backports to your apt sources and set the right preferences.
# vi /etc/apt/sources.list deb http://www.backports.org/debian/ sarge-backports main
If /etc/apt/preferences does not exist, create it.
# vi /etc/apt/preferences Package: * Pin: release a=sarge-backports Pin-Priority: 200 Package: xen-3.0 Pin: release a=sarge-backports Pin-Priority: 999 Package: linux-2.6 Pin: release a=sarge-backports Pin-Priority: 999 Package: xen-tools Pin: release a=sarge-backports Pin-Priority: 999 Package: udev Pin: release a=sarge-backports Pin-Priority: 999 Package: lsb Pin: release a=sarge-backports Pin-Priority: 999 Package: module-init-tools Pin: release a=sarge-backports Pin-Priority: 999 Package: grub Pin: release a=sarge-backports Pin-Priority: 999
Now update your sources:
# apt-get update && apt-get dist-upgrade
If that works, you're ready to start installing packages. If it doesn't, there is more information about backports on their website: http://www.backports.org.
Since there are some dependency problems with grub and mdadm we pull them, and some other packages, from backports.
# apt-get install grub/sarge-backports # apt-get install makedev/sarge-backports # apt-get install lsb-base/sarge-backports # apt-get install mdadm/sarge-backports
The next things to install are the Xen-hypervisor and the xen-utils.
# apt-get install xen-hypervisor-3.0-i386 xen-utils-3.0
Pick the right kernel. A 686 for P4 and Xeon machines and K7 for Athlon and Opteron machines.
# apt-get install linux-image-2.6.16-2-xen-686
Remove hotplug because we're changing to udev!
# dpkg --purge hotplug # apt-get install bridge-utils xen-tools/sarge-backports sysfsutils # mv /lib/tls/ /lib/tls.disabled
You need a new initrd. mkinitramfs can do that trick for you.
# cd /boot # mkinitramfs -o /boot/initrd.img-2.6.16-2-xen-686 2.6.16-2-xen-686
For this machine, we need a k7 kernel:
# apt-get install linux-image-2.6.16-2-xen-k7 # cd /boot # mkinitramfs -o /boot/initrd.img-2.6.16-2-xen-k7 2.6.16-2-xen-k7
We need to setup our bootloader to use the new Xen kernel. Add something like the following to your /boot/grub/menu.lst file:
# vi /boot/grub/menu.lst title Xen 3.0 / XenLinux 2.6-686 kernel /boot/xen-3.0-i386.gz module /boot/vmlinuz-2.6.16-2-xen-686 root=/dev/md0 ro module /boot/initrd.img-2.6.16-2-xen-686
or the with k7 if you have an Athlon or Opteron machine:
title Xen 3.0 / XenLinux 2.6-k7 kernel /boot/xen-3.0-i386.gz module /boot/vmlinuz-2.6.16-2-xen-k7 root=/dev/md0 ro module /boot/initrd.img-2.6.16-2-xen-k7
The xen daemon needs some tweaks, open the config file and make sure that you enable (network-script network-bridge) (line 73), (vif-script vif-bridge) (line 104).
# vi /etc/xen/xend-config.sxp
Restart the Xen daemon to check if the new settings are accepted:
# invoke-rc.d xend restart # reboot
In most cases the bridge will work after a reboot, but it's easy to check. Peth0 and vif0.0 should be in the interfaces list. Peth0 is the physical network device and vif0.0
# brctl show
You are ready to setup and start your xens! Setting up xens has been covered many times all over the net. The easiest way is probably to use the xen-tools created by Steve. Although they are pretty straightforward, there is some documentation on how to use them at the end of this article: http://www.debian-administration.org/articles/396
There are a few things you need to pay attention to when setting up xens. The first is to copy the modules to the xen guest. For instance, you could mount your first xen on /mnt/xen1 and copy the modules:
# cp -a /lib/modules/2.6.16-2-xen-k7/ /mnt/xen1/lib/modules/
The config file is the second thing. The ramdisk option is turned off by default but required to start a xen! For example:
# vi /etc/xen/xen1.cfg kernel = '/boot/vmlinuz-2.6.16-2-xen-k7' memory = 128 name = 'xen1' disk = [ 'phy:/dev/mapper/xens-xen1,sda1,w' ] root = "/dev/sda1 ro" extra = '4' ramdisk = "/boot/initrd.img-2.6.16-2-xen-k7" vif = [ 'vifname=vif_xen1,bridge=xenbr0' ]
If you need to upgrade the Xen kernel, don't forget to update the configuration files for the guests, the initrds and the modules on the Xen guests!
There is a copy of this howto on my company's website: http://www.virtualconcepts.nl/xenbackports.php