Xen Install

From ArchWiki

Jump to: navigation, search


Contents

[edit] Introduction

This document will cover installing Xen on Archlinux.
by: cactus 23:22, 6 Sep 2005 (EDT)

Much of the information comes directly from the Xen Install Doc.

More info about Xen here:
Wikipedia Xen Article
Main Xen site

[edit] Requirements

You need to fulfill the requirements before you can get Xen running. Those requirements are:

  • iproute
  • bridge-utils
  • twisted-web
  • libcurl

[edit] Install

[edit] Fulfill the Requirements

Fetch pacman packages.

$ pacman -Sy iproute bridge-utils zope python twisted curl

[edit] Fetch Xen Binaries

Download the Xen binaries from The Xen Download Site.

$ wget http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/xen-2.0.7-install-x86_32.tgz

[edit] Extract Xen Binaries

< you need to become root user here >

$ su
$ tar -xpzf xen-2.0.7-install-x86_32.tgz
$ cd xen-2.0-install

[edit] Modification of files

Some of the Xen files need to be modified.

$ edit install.sh change all init.d to rc.d
$ cd install
$ cd etc
$ mv init.d rc.d
$ cd ../usr/lib/
$ mv python python2.4
$ cd python2.4/xen
$ sed -i "s#twisted.protocols import http#twisted.web import http#g" xend/XendAsynchProtocol.py \
  xend/server/SrvDomainDir.py xend/server/SrvDir.py xend/server/SrvBase.py xend/server/SrvDomain.py
$ cd ../../../../..
$ sh install.sh

[edit] Configuration Xen

[edit] Grub

$ vi /boot/grub/menu.lst

Add the following before the current grub entry.

title  Xen [/boot/xen.gz]
root   (hd0,1)
kernel /xen.gz dom0_mem=524288
module /vmlinuz-2.6.11.12-xen0 root=/dev/sda5 ro

Of course, replace your information as appropriate. Namely, the root device, and specify an appropriate value for dom0_mem=NUMBER, where NUMBER is the amount of memory (in kilobytes) you wish to dedicate to the main Xen instance (the host).

[edit] Rebooting

Now you need to reboot into your new kernel/Xen0 host instance. If the system does not boot, then just reboot with the previous kernel grub entry, and attempt to fix the errors.

[edit] Starting Xen Daemon

After a successful kernel reboot, start xend.

$ /etc/rc.d/xend start

If you get any errors, attempt to fix them.

[edit] Creating a xenU instance

[edit] The /etc/xen file

You need to create a domain configuration file for your xenU instance.

Here is a simple example. The useful comments have been removed. If you wish to delve deeper, the xmexample1 and xmexample2 files contain more information. Just copy them to a custom filename, and edit away.

Here is the example used for this how to:

#  -*- mode: python; -*-
#============================================================================

# Kernel image file.
kernel = "/boot/vmlinuz-2.6.11-xenU"

# Initial memory allocation (in megabytes) for the new domain.
memory = 256

# A name for your domain. All domains must have different names.
name = "WebServer"

disk = [ 'file:/home/xen/webserver,hda1,w','file:/home/xen/webserver-swap,hda2,w' ]

# Set root device.
root = "/dev/hda1 ro"

# Sets runlevel 4.
extra = "3"

restart = 'onreboot'

Name the file webserver for the purposes of this example. /etc/xen/webserver

[edit] Create data files

$ cd /home
$ mkdir xen
$ cd xen
$ dd if=/dev/zero of=webserver-swap bs=1k seek=768k count=1
$ dd if=/dev/zero of=webserver bs=1k seek=2048k count=1
$ mkfs -t ext3 webserver
$ mkswap webserver-swap

[edit] Populate xenU instance

We now need to populate our xen vm instance. I installed Xen on a pretty barebones/fresh Arch install. I took the following steps to get a usable vm isntall.

$ mount -o loop webserver /mnt/fl/
$ cp -ax /{root,dev,var,etc,usr,bin,sbin,lib} /mnt/fl/
$ cd /mnt/fl
$ mkdir {proc,sys,home,tmp}
$ vi /mnt/fl/etc/inittab
< remove all but the first agetty respawn lines >
$ vi /mnt/fl/etc/rc.conf
< modify ip address, hostname, and anything else you desire >
$ cd 
$ umount /mnt/fl

[edit] Start XenU instance

$ xm create /etc/xen/webserver -c

Special note: If you use the -c flag, the tty will attach to that the xenU instance being started. You will see the kernel start output, as well as receive a login. All the other tty's on the box will remain attached to the host xen0 system. If you leave off the -c, then it will not attach directly, and will instead start in the 'background'.

[edit] Login and configure your installation

Since this is a copy of the host system, I recommend modifying your user/group information. Namely, changing the root password, and removing/adding users as needed. Once that is done, the xenU instance behaves just like a standalone system, while inside the xenU tty. You can ssh to the system, run services, install things with pacman, etc.

[edit] More info

[edit] Instance Management

From the xen0, or host system, you can manage your xenU, or user subsystems. The management interface is xm.

$ xm help

It is also advisable to add xend to your DAEMONS array list in the xen0 system's /etc/rc.conf


[edit] Addendum

Check out the talk for this page:
Talk:Xen_Install

Personal tools