Xen 
 
Home Products Support Community News
 
   

Page under development - JamesBulpin

Introduction

This page presents a step-by-step guide to getting a Xen system up and running. This guide is aimed at Linux distributions that do not ship with Xen. For per-distribution guides, please see the relevant page amnd return here for post-install steps:

  • SusePro: SUSE Pro 9.3 ships with a version of Xen 2.0.5, installable as an option.

There are a number of different ways to configure a Xen system, with variations possible in areas including storage and networking. On this page we present a basic configuration suitable to get started.

Assumptions

The starting point is a working Linux installation. In particular we assume the following:

  • The system runs a P6 or newer processor (e.g. Pentium 2 upwards), or a modern AMD processor. What do we support form on AMD? - JamesBulpin

  • The system boots using GRUB.
  • The system currently has a 2.6 kernel.
  • You have root privileges on the system.

If you are installing a fresh system then there are some steps you can take that will give you flexibilty later, see InstallingAFreshSystem. There is no need to reinstall to get a basic Xen system running.

The steps on this page are generally independent of distribution but where a distribution requires a different action, that will be noted. We cover RedHat-based distributions such as RHEL, CentOS and Fedora; SUSE systems including Pro 9.3 and SLES; and Debian sarge. Derived distributions will most likely work in a similar manner to the parent distribution.

Need to confirm steps on each distribution - JamesBulpin

Getting and Installing Xen

A binary distribution of Xen, XenLinux kernels and control tools can be found on the XenDownloads page. Get the latest stable release. The tarball (*.tgz file) contains files which can be used on any Linux distribution.

Alternatively, if package(s) are available for your distribution then you can download those and install using the standard package tool (e.g. rpm or dpkg).

If using the tarball distribution, you will need to ensure the following software package are installed. Please consult your distribution documentation to find out how to install new packages.

  • iproute2 (the ip command. This package is called iproute with a 2.x version number in some cases)

  • Linux bridge-utils (the brctl command.)

  • Python
  • Python Twisted v1.3 or above.

For example, on Debian sarge:

apt-get install iproute bridge-utils python python-twisted

RHEL/CentOS will need packages: iproute (2.x), python and bridge-utils, and an install of Twisted from http://www.twistedmatrix.com/.

To install the Xen binaries, change to a temporary directory, e.g. /tmp and unpack the file (check the version in the filename is correct, there may be a newer version available since this guide was written). Then run the install script (as root).

tar zxvf xen-2.0.6-install.tgz
cd xen-2.0-install
sh ./install.sh

The installation script will check that the required packages described above are installed.

This script installs the following (this is for information only, no need to worry about it):

  • The Xen hypervisor, xen.gz, and XenLinux kernels to /boot

  • Kernel modules to /lib/modules

  • Libraries for the Xen control tools ot /usr/lib

  • Python libraries or the Xen control tools ot /usr/lib/python

  • Xen-specific header files to /usr/include/xen

  • Xen control tools to /usr/bin and /usr/sbin

  • Documentation to /usr/share/doc/xen

  • Xen control initialisation scripts to /etc/init.d

  • Xen configuration files is /etc/xen

initrd?

An initrd is usually used on systems where the kernel needs to load modules to be able to access its root filesystem (which contains the modules!). The binary distribution has most device drivers compiled into the kernel which avoid the need for an initrd in most cases.

However, some distributions, including recent RHEL and CentOS, require certain parts of the enviroment to be set up by the initrd before the main system startup scripts run. An initrd can be made by running the following commands.

/sbin/depmod -a 2.6.11-xen0
/sbin/mkinitrd /boot/initrd-2.6.11-xen0.img 2.6.11-xen0

If mkinitrd complains about missing modules, it is likely that you have a SCSI disk that has a module driver on your current system but that driver is compiled in to the XenLinux kernel. In this case, try:

/sbin/mkinitrd --omit-scsi-modules /boot/initrd-2.6.11-xen0.img 2.6.11-xen0

Configuring GRUB

Xen requires a new boot entry becuase the Xen hypervisor starts before the first Linux domain. This is configured by editing the GRUB configuration which is /boot/grub/menu.lst or /boot/grub/grub.conf (if neither of these exist, please check your system uses grub by watching the boot sequence and search for a file called menu.lst).

Add an entry similar to the following to the end of your GRUB configuration:

title Xen 2.0
    kernel /boot/xen.gz dom0_mem=262144
    module /boot/vmlinuz-2.6.11-xen0 root=/dev/sda4 ro 

Have a look at existing entries in the file and modify the Xen entry to look similar. For example, if the entry for your kernel looks like: kernel (hd0,0)/boot/vmlinuz-2.6.7-myvendor ... then make sure the Xen entry has module (hd0,0)/boot/vmlinuz-2.6.11-xen0 .... If the existing entries do not have /boot at the start of the paths then you have a separate boot partition; remove /boot from all lines in the Xen entry too.

root= should match what you have for your existing kernel.

dom0_mem=262144 specifies how much memory (in kilobytes) to initially allocate to the first domain. This will vary depending on how much RAM you have in your system and how many domains you want to run. The maximum is 40MB less than you have in the system (the Xen hypervisor requires 40MB for itself); the minimum will depend on the distribution your have and what you plan on doing in the first domain. 128MB to 256MB is a good value for basic systems, with 512MB being suitable if you have a lot of programs running in the first domain.

If you created an initrd, also add the following line to the Xen entry (yes, that is two module lines and no initrd line):

    module /boot/initrd-2.6.11-xen0.img

For now, do not change the default= line.

Starting the System

Reboot the system and watch for the GRUB screen. Press which ever keys you need to get to the grub menu and select the "Xen 2.0" option you created above. If everything is OK, this will boot the Xen hypervisor and you will see output on the console starting "(XEN)". After a few seconds Xen will start the first domain and you will see a standard Linux boot sequence. If everything works correctly then you will eventually get to a login prompt (text or X windows) as you would normally. If the boot fails then visit the XenTroubleshooting page.

Log into the machine and check the kernel version using the command uname -r. It should return 2.6.11-xen0. If it doesn't, you may have missed the GRUB timeout and booted into the existing Linux kernel.

You can now start the Xen control daemon, "xend":

/etc/init.d/xend start

You can set this to start automatically on boot using:

on RedHat, Fedora, CentOS and SUSE:

/sbin/chkconfig --add xend
/sbin/chkconfig xend on

on Debian:

/usr/sbin/update-rc.d xend defaults

You can now use the "xm" command to control your Xen-based machine. Try xm --list, you should see something like:

Name              Id  Mem(MB)  CPU  State  Time(s)  Console
Domain-0           0      251    0  r----     18.8        

This shows that the only running domain is the one we're using now (domain 0), it has a current allocation of 251MB of RAM, is using CPU 0, is running, and has consumed 18.8 seconds of processor time (this is actual processing, not elapsed time). There is no console entry, this is used for connecting to the virtual text console of additional domains.

At this point you may wish to check your network connectivity works correctly. As part of xend's startup, it created a software bridge, "xen-br0", which currently connects the physical network interface, eth0, and the only running domain. If you have network problems, it is likely to be due to an interaction between the naming of the domain's network interface (now "xen-br0") and any firewall (iptables) configuration. See XenTroubleshooting for more information.

If everything worked OK, then you can edit the GRUB configuration to change the default to be Xen rather than the existing Linux kernel. This can be done by editing (or adding if necessary) the default= line in the top area of the file. Count the entries (they start with "title") down from 0 to get the number to put in the default line. For example, if the GRUB configuration has 4 entries and "Xen 2.0" is the last one then the line should be default = 3. This line should appear somewhere before the first "title" entry.

Creating Additional Domains

So far, we have covered getting Xen installed on a machine and booting it with the first domain, "domain 0". You will certainly want to create additional domains (or "virtual machines"). There are two steps needed to create an additional domain:

  1. Create a root filesystem for the new domain.
  2. Create a configuration file.

Root Filesystem

Partition

LVM

file

install from media

rpmstrap

debootstrap

yast

cp -a or dd

http://www.xen-get.org/

http://jailtime.org

general considerations

modules fstab /dev

Configuration

/etc/xen

basic example. see user guide for more

If you want additional domains to be automatically started when the system boots, create a symbolic link to each configuration file required to be started from the directory /etc/xen/auto. Set the "xendomains" init.d script to run:

on RedHat, Fedora, CentOS and SUSE:

/sbin/chkconfig --add xendomains
/sbin/chkconfig xendomains on

on Debian:

/usr/sbin/update-rc.d xendomains defaults

Further Information

Browse all the Xen documentation, including the full user guide (which contains more detailed instructions than this simple getting started guide).

GettingStarted (last edited 2006-04-18 05:59:44 by RogerKlorese)