P.S. So now we've gotten to the point where it's time to write a reminder for the community - how to install Xen 4.2 on our beloved Debian.
Today our task is to install Xen 4.2 (in our case - 4.2.1) on Linux Debian Squeeze. Squeeze has no built-in support for the new Xen - the latest official version is 4.0.1-4 (at the time of writing this note), so we'll have to build everything from source.
1) Log in to the host machine and download Xen 4.2.
$ wget http://bits.xensource.com/oss-xen/release/4.2.1/xen-4.2.1.tar.gz
Unpack it:
$ tar -xzf xen-4.2.1.tar.gz
After that we get a xen-4.2.1 directory, which contains the hypervisor sources.
2) Install the dependencies.
Do this before compiling and building the hypervisor, since otherwise nothing will work.
$ sudo apt-get build-dep xen
$ sudo apt-get install libx11-dev libssl-dev python2.6-dev
$ sudo apt-get install bridge-utils
$ sudo apt-get install bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev \
bzip2 module-init-tools transfig tgif texinfo texlive-latex-base \
texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended \
pciutils-dev mercurial make gcc libc6-dev zlib1g-dev python python-dev \
python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev \
iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml ocaml-findlib libx11-dev \
bison flex xz-utils libyajl-dev gettext pkg-config
3) Build and install Xen 4.2
$ cd xen-4.2.1
$ ./configure
$ sudo make dist
$ sudo make install PYTHON_PREFIX_ARG=
4) Add the Xen daemons to autostart
$ sudo update-rc.d xencommons defaults
$ sudo update-rc.d xendomains defaults
Note that the xend daemon is now considered deprecated, and Xen's developers recommend against running it. Instead, they suggest (starting with 4.1 experimentally, and now for production configurations as well) using XL.
5) Add loading of the required modules. To do this, open the file
/etc/modules
And add the following lines:
loop max_loop=64
blktap
xen-evtchn
The max_loop parameter determines the maximum number of Loop devices that can be created - such as a virtual hard disk, virtual network card, etc. It's counted across all machines in total, so it's best not to set it too low - unless you only plan to run a couple of machines. In my personal experience, 64 has never been too little anywhere.
6) Install the kernel needed to work with Xen. The kernel that comes "out of the box" - 2.6.32-5 - will do fine.
$ sudo apt-get install linux-image-2.6.32-5-xen-amd64 linux-headers-2.6.32-5-xen-amd64
As you can see, this example is for a 64-bit OS (amd64). If yours is 32-bit, install the corresponding kernel.
7) Now we need to make Xen start first, and actually start at all. First, go to /boot and get rid of the xen-syms-4.2.1 file, for example by moving it somewhere else:
$ cd /boot
$ sudo mkdir xsyms
$ sudo mv xen-syms-4.2.1 xsyms
Now let's head into the Grub configuration (/etc/grub.d). The thing is, by default Xen is placed in the boot menu after the regular kernels, which means that on reboot you have to select the Xen option by hand. We'll have to fix this nonsense manually:
$ cd /etc/grub.d
$ sudo mv 20_linux_xen 09_linux_xen
Here we moved Xen's boot entry to first place (sort index = 09). Now on reboot the hypervisor with domain-0 will load automatically.
But we still need to rebuild the Grub configuration:
$ sudo update-grub
9) Configuring Xen.
To do this, open the /etc/xen/xend-config.sxp file and edit it. For your initial setup I recommend uncommenting the line that enables VNC access to the virtual machine consoles:
(vnc-listen '0.0.0.0')
(by the way, the default is 127.0.0.1, which is completely useless - since there's no X-Window on the hypervisor itself, because who needs one there anyway - there's simply nothing to connect to the VNC console from 127.0.0.1 with, so we set the value to 0.0.0.0, allowing connections from anywhere).
10) Configuring the network.
Starting with Xen 4.1 (and continuing in Xen 4.2), the built-in network-bridge tool can only be used to configure a single network card. What's more, the developers themselves strongly recommend setting up bridges using the hypervisor OS's own tools - in our case, using Linux Debian. Let's do exactly that.
The bridge is set up using the most standard methods - like any other bridge on Debian. Here's an example config.
/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto xeth0
iface xeth0 inet static
bridge_ports eth0
address 10.0.34.200
netmask 255.255.255.0
network 10.0.34.0
broadcast 10.0.34.255
gateway 10.0.34.250
auto xeth1
iface xeth1 inet static
bridge_ports eth1
address 10.3.34.200
netmask 255.255.255.0
# The primary network interface
#allow-hotplug eth0
#iface eth0 inet static
# address 10.0.34.200
# netmask 255.255.255.0
# network 10.0.34.0
# broadcast 10.0.34.255
# gateway 10.0.34.250
# # dns-* options are implemented by the resolvconf package, if installed
# dns-nameservers 10.0.1.10
This simple file shows bringing up two bridges, xeth0 and xeth1 (which can later be used for virtual machines). The bridges get IP addresses assigned — notice that it's not the eth0 and eth1 interfaces themselves, but specifically the xeth0 and xeth1 bridges.
11) Reboot.
To check that everything is "up and running", let's ask Xen to show the list of current machines:
$ sudo xl list
Name ID Mem VCPUs State Time(s)
Domain-0 0 32320 8 r----- 782440.2
By the way, notice also that I'm no longer using xm to manage the machines, but xl.
Comments