Xen Installation and Configuration Guide

From The Wiki Guide

(Redirected from Xen on Gentoo)
Jump to: navigation, search

Contents

Abstract

Xen is an open-source virtual machine monitor, or hypervisor, developed by the University of Cambridge. It has a design goal of being able to run 100 full-featured operating system (OS) instances on a single typical computer. Xen provides secure isolation, resource control, quality-of-service guarantees, and live migration of virtual machines. Operating systems must be explicitly modified ("ported") to run on Xen (although compatibility is maintained for user applications). This enables Xen to achieve high-performance virtualization without special hardware support.

Requirements

Linux with 2.6 kernel (Gentoo, Fedora, CentOS)
GRUB Bootloader
iproute2 [1]
Linux bridge-utils [2]
Linux hotplug system or udev
Build tools (gcc v3.2.x or v3.3.x, binutils, GNU make)
Development installation of zlib (e.g., zlib-dev)
Development installation of Python v2.2 or later (e.g., python-dev)

Although XEN is supported with the 2.4 kernel, it is recommended to use the latest kernel to take advantage of the newest options the 2.6 kernel has to offer.

Installation

Gentoo

Xen is still ~arch masked.
Unmask in: /etc/portage/package.keywords

app-emulation/xen ~x86
app-emulation/xen-tools ~x86
sys-devel/dev86 ~x86
sys-kernel/xen-sources ~x86

Install the hypervisor and applications

emerge --ask --verbose app-emulation/xen app-emulation/xen-tools sys-kernel/xensources
rc-update add xend default (this starts the xen daemon on boot)
Note:
If your network interface (ex. eth0) is initiated during the boot, disabled it because the xend will take care of initializing the interface.
rc-update del net.eth0

The xen hypervisor is installed in /boot/xen.gz (app-emulation/xen).


Source

Download the source [3]

tar zxvf xen-3.0.x.tgz
cd xen-3.0.x
make xen     # build and install Xen hypervisor
make tools   # build and install tools
make kernels KERNELS="linux-2.6-xen0 linux-2.6-xenU" # build and install guest kernels
make install

Building the Xen Kernel for the Host System

In /usr/src/linux-2.6.x.y-xen you will now find the sources required to build the kernel for a Xen domain.

It is recommended to build two separate kernels, one for domain 0, and one for domain U. You can use modules, but all drivers required to boot must be builtin.

The Xen kernel config can be difficult to configure - there are many options, some of which will cause your dom0 or domU kernels to fail on booting (eg. with errors opening the root device). If you have problems, try the default Xen configs in /usr/src/linux/arch/xen/configs.

 Xen --->
 [*] Privileged Guest (domain 0)
 < > PCI device backend driver
 <*> Block-device backend driver
 < >   Block Tap support for backend driver (DANGEROUS)
 <*> Network-device backend driver
 [ ]   Pipelined transmitter (DANGEROUS)
 <*>   Network-device loopback driver
 < > TPM-device backend driver
 < > Block-device frontend driver
 < > Network-device frontend driver
 < > Block device tap driver
 < > TPM-device frontend driver
 [*] Scrub memory before freeing it to Xen
 [ ] Disable serial port drivers
 <*> Export Xen attributes in sysfs

Networking --->

 Networking options --->
   [*] IP: tunneling
   [*] 802.1d Ethernet Bridging
make && make modules_install
cp vmlinuz /boot/vmlinuz-2.6.x.y-xen0

The domain 0 kernel should contain drivers for Xen backend devices, and all of your usual hardware. Ethernet bridging support is required in order to bridge domain U kernels to a domain 0 /dev/eth device, as well as Network-device loopback driver. This is the default set by /etc/xen/scripts/vif-bridge when a domain is created. An alternative is to use IP routing in domain 0 if you want to keep domain U isolated from the external ethernet - this is set up in /etc/xen/scripts/vif-route.

Building the Xen Kernel for the Guest System (XenU)

In /usr/src/linux-2.6.x.y-xen you will now find the sources required to build the kernel for a XenU domain.

 Xen --->
 [ ] Privileged Guest (domain 0)
 [ ]  Block-device backend driver
 [ ]  Network-device backend driver
 [*] Block-device frontend driver
 [*] Network-device frontend driver
 [ ]   Piplined transmitter (DANGEROUS)
 [*] Scrub memory before freeing it to Xen
     Processor Type (X86)
make && make modules_install
cp vmlinuz /boot/vmlinuz-2.6.x.y-xenU

The domain U kernel should contain only Xen frontend drivers since it has no real hardware.


Grub Configuration

title  Xen 3.0 / Linux 2.6.x.y
root   (hd0,0)
kernel /xen.gz dom0_mem=98304
module /vmlinuz-2.6.x.y-xen0 root=/dev/md2

dom0_mem=xxx will allocate the specified amount of ram for the host system leaving the remaining memory for the guest OS's.

Running Xen

Reboot and choose Xen 3.0 / Linux 2.6.x.y in the GRUB Bootloader.

This should be the result

\ \/ /___ _ __   |___ / / _ \     __| | _____   _____| |
 \  // _ \ '_ \    |_ \| | | |__ / _` |/ _ \ \ / / _ \ |
 /  \  __/ | | |  ___) | |_| |__| (_| |  __/\ V /  __/ |
/_/\_\___|_| |_| |____(_)___/    \__,_|\___| \_/ \___|_|
http://www.cl.cam.ac.uk/netos/xen University of Cambridge Computer Laboratory
Xen version 3.0-devel (portage@edesix.com) (gcc version 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)) Tue Sep 6 17:30:34 BST 2005 Latest ChangeSet:
(XEN) Physical RAM map: (XEN) 0000000000000000 - 00000000000a0000 (usable) (XEN) 00000000000f0000 - 0000000000100000 (reserved) (XEN) 0000000000100000 - 000000003fe8cc00 (usable) (XEN) 000000003fe8cc00 - 000000003fe8ec00 (ACPI NVS) (XEN) 000000003fe8ec00 - 000000003fe90c00 (ACPI data) (XEN) 000000003fe90c00 - 0000000040000000 (reserved) (XEN) 00000000f0000000 - 00000000f4000000 (reserved) (XEN) 00000000fec00000 - 00000000fed00400 (reserved) (XEN) 00000000fed20000 - 00000000feda0000 (reserved) (XEN) 00000000fee00000 - 00000000fef00000 (reserved) (XEN) 00000000ffb00000 - 0000000100000000 (reserved) ......

Once the Hypervisor has loaded, it will boot your kernel. You should see something like:

*** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen).
Linux version 2.6.12.5-xen (root@funky.edesix.com) (gcc version 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)) #2 Tue Sep 6 18:30:28 BST 2005
BIOS-provided physical RAM map:
Xen: 0000000000000000 - 0000000006000000 (usable)
96MB LOWMEM available.
On node 0 totalpages: 2

References

Personal tools