wiki:xen

Version 5 (modified by dkg, 6 years ago) (diff)

--

Xen

Xen is a popular free virtualization environment. The hardware boots a "hypervisor", which in turn loads a kernel as the first virtualized machine (known as the dom0). The dom0 has privileged access to the hardware, and can instruct the hypervisor to allocate access to the hardware to the other virtualized machines (known as domUs).

setting up Xen on debian

On debian etch (4.0), the standard kernels don't have the capability to run under Xen virtualization yet, so you need specialized xen-specific kernels. if you're using amd64 as your architecture, replace 686 below with amd64 -- 686 and amd64 are the only two architectures supported by xen in debian etch.

The simplest way to set up a Xen environment after installation is:

aptitude install xen-linux-system-2.6.18-4-xen-686 linux-image-2.6-xen-686 bridge-utils libc6-xen

Once these packages are installed, you'll want to make a handful of modifications:

limit memory consumed by dom0

to do this, you'll want to modify /boot/grub/menu.lst. Change the # xenhopt= line to include a dom0_mem value (this is specified in kilobytes). Here's an example working with 128MiB for the dom0:

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=dom0_mem=131072

Do not uncomment these lines! The # xenhopt= line is used by update-grub to configure the "automagic" stanzas. To make sure the update propagates to those stanzas, as root, run:

update-grub

You should see the changes reflected in the automagic stanzas that include the Xen hypervisor.

ask for bridged networking

There are a lot of different virtualized networking environments you might want to use with Xen. By far the simplest is the "bridged" environment. This emulates having each of your domUs on a network hub. Each machine can see the traffic entering and leaving each other machine. This makes it more likely that individual machines could spoof each other or eavesdrop on each other on the network, so if you need more network isolation of the machines, you should consider using a fancier virtualized networking arrangement.

To set up a bridged virtualized network, modify /etc/xen/xend-config.sxp on the dom0: comment out the line that says:

(network-script network-dummy)

and uncomment:

(network-script network-bridge)

install xen-tools

xen-tools is a very convenient package for managing a Xen server. Install it and read through /etc/xen-tools/xen-tools.conf, changing values to match how you plan to run the machine. We at CMRG recommend using LVM wherever possible, so consider that.

with all of the above changes made, you should now be able to reboot your machine, and it will come up as the dom0.

==upgrading Xen on debian==

when a new kernel comes in, you'll want to make sure the new kernel is available to all your virtual machines (dom0 and all the domUs). This can be tricky to get right. The kernel for the dom0 is properly handled by grub. But the kernels for the domUs need to be modified in their config files in /etc/xen/domUname.cfg. I've found in etch at least that you'll need to restart the domU via the dom0 to get the new kernel as well.

That is, simply running

root@domU:~# shutdown -r now

is not enough to pick up changes in the configuration file. Instead, you should do:

root@dom0:~# xm shutdown domU
root@dom0:~# xm create domU.cfg