Binqbu2002:Xen4.0 installation

From Xen

First,You should install CentOS 5.5 X86-64,You can refer Qian's guide CentOS5.5 Installation

Install Xen4.0.1

Of course,you should download xen-4.0.1.tar.gz and target it.

Step 1: Necessary tarball list for Xen-4.0.1

  • newlib-1.16.0.tar.gz
  • lwip-1.3.0.tar.gz
  • zlib-1.2.3.tar.gz
  • pciutils-2.2.9.tar.bz2
  • grub-0.97.tar.gz

You can get them on

Download and place them in xen-4.0.1/stumdom/

Step 2: Install dependence

The necessary dependence are listed as following:

  • gcc v3.4 or later
  • make
  • binutils
  • development install of zlib (e.g., zlib-dev)
  • development install of Python v2.3 or later (e.g., python-dev)
  • development install of curses (e.g., libncurses-dev)
  • development install of openssl (e.g., openssl-dev)
  • development install of x11 (e.g. xorg-x11-dev)
  • bridge-utils package (/sbin/brctl)
  • iproute package (/sbin/ip)
  • hotplug or udev
  • gawk
  • gettext
  • texinfo
  • transfig
  • development install of libssl (e.g. libssl-dev)
  • bcc
  • ACPI ASL compiler (iasl)
  • latex relevance (e.g. texlive-latex-xxx, tetex-xxx, latex2html, latex2pdf)
  • mercurial (NOTE: This can be unnecessary if you don't need the hg support.)
  • git (NOTE: This can be unnecessary if you don't need the Git support.)
  • qemu

of course ,the following are important.

yum install binutils zlib-devel python-devel
yum install ncurses-devel openssl-devel bridge-utils 
yum install iproute gettext texinfo*
yum install transfig dev86 vnc
yum install latex*
yum install mercurial

Step 3: Prepare domain0 kernel

You should download the domain0 kernel:linux-xen.stable-2.6.32.x.tar.gz on to xen-4.0.1.

tar zxvf  linux-xen.stable-2.6.32.x.tar.gz 

note:In our installation,we use that


Step 4:Compile and Install

When all things are ready, you need to obtain root permission. OK, start sailing!

make clean
make dist KERNELS=linux-2.6-pvops
make install KERNELS=linux-2.6-pvops

After the installation finish, you can see "xend" and "xendomains" in /etc/init.d/ directory.

Step 5:Modify the config

Be careful that if you refuse this step,you could find this error when you reboot to Xen-4.0.1 :

RedHat nash Version startingrver(
mount: could not find filesystem ‘/dev/root’
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic – not syncing: Attempted to kill init!
[Linux-initrd @ 0x1fc37000,0x228585 bytes]

so, after compiling,you should do the following step:

  • modify the .config on xen-4.0.1/build-linux-2.6-prvops_x86_64/
  • set


cd build-*
make modules_install
make install

Step 6 :Create booting

You should return to root to do this

su -
mkinitrd -v -f /boot/initrd- \
	--builtin=pata_marvell \
    --builtin=ehci-hcd --builtin=ohci-hcd --builtin=uhci-hcd --builtin=ahci --builtin=ata_piix

After this,you can find initrd- in /boot

Then,modify grub

add Xen start

 title Xen Dom0, kernel
    root (hd0,0)
    kernel /xen-4.0.1.gz dom0_mem=512M
    module /vmlinuz- root=LABEL=/ rhgb quiet
    module /initrd-

NOTE: Details should be similar to other entries, e.g. the value of root.

Ok,now ,reboot

Create Domain U

  • PLEASE LOG IN AS root!!!!
  • First, create a hard disk .img file in console, "qemu-img" is a tool, "create" is the subcommand, "xxx.img" is the target image

Create a hard disk

(this way is faster)

qemu-img create xxx.img 20G

or (the old way, which is very slow and you will hear harddisk crying)

dd if=/dev/zero of=xxx.img bs=1024k count=2048

xend start

so,you can excute

xend start

if you find the error

> ERROR Internal error: Could not obtain handle on privileged command 
> interface (2 = No such file or directory)
> Traceback (most recent call last):
>   File "/usr/sbin/xend", line 36, in <module>
>     from xen.xend.server import SrvDaemon
>   File "usr/lib/python2.5/site-packages/xen/xend/server/", 
> line 26, in <module>
>   File "usr/lib/python2.5/site-packages/xen/xend/server/", 
> line 28, in <module>
>   File "usr/lib/python2.5/site-packages/xen/xend/", line 
> 35, in <module>
>   File "usr/lib/python2.5/site-packages/xen/xend/", 
> line 20, in <module>
>   File "usr/lib/python2.5/site-packages/xen/xend/", line 46, 
> in <module>
> xen.lowlevel.xc.Error: (1, 'Internal error', 'Could not obtain handle 
> on privileged command interface (2 = No such file or directory)')

you should do the following

modify /etc/fstab by adding:

none /proc/xen xenfs defaults 0 0

more solution,you can refer xend start problem

create winxp config file

If you want to create a domainU and want to install winxp on it ,you should create a winxp config file and copy the following

import os, re

arch = os.uname()[4]

if'64', arch):
    arch_libdir = 'lib64'
    arch_libdir = 'lib'

kernel = "/usr/lib/xen/boot/hvmloader"


memory = 1024 

name = "winxp"

vcpus = 1
#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3

#vif = [ 'type=vnif, mac=00:16:3e:00:00:11' ]

disk = ['file:/root/xxx.img,hda,w', 'phy:/dev/cdrom,hdc:cdrom,r']
#disk = ['file:/var/lib/xen/images/winxp.img,hda,w','phy:/dev/cdrom,hdc:cdrom,r']

on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

device_model = '/usr/lib/xen/bin/qemu-dm'



#cpuid = [ '0x40000002:edx=0x3' ]

#mouse adjustment

#guest os debug support
serial = 'pty'
#serial = 'tcp::4444,server,nowait'

Notice:disk = ['file:/root/xxx.img,hda,w', 'phy:/dev/cdrom,hdc:cdrom,r'] the file path is your domain U path!!

launch xend

xend start
  • Launch a console, cd to the config file directory, type in: (winxp is the name of the config file)
xm create winxp
  • Type following to "see" domain U. "xm create" only launches the domainU and runs it at "background", so you need to use vnc (a remote desktop) to connect to domainU display.
xm vnc winxp

If everything goes well, you can see the black booting screen in the Domain U.

  • Note: Sometimes, the domainU is created but disappear immediately. Please put a bootable CD in the CD-ROM in advance.
  • If there is nothing, you can use:
xm list

to check if winxp has been launched.


Qian's XEN4.0 Installation Script

Of course,Qian give a wonderful Installation Script of Xen-4.0.0,We should thanks to him and we can refer his scription


echo "Deleting previous Xen directory."
rm -rf $XEN

echo "Extracting Xen source package ..."
tar xzf $XEN.tar.gz
echo "Extracting Dom0 kernel ..."
tar xzf $DOM0_SRC -C $XEN
echo "Preparing stubdom packages ..."
cp stubdom_pkg/* $XEN/stubdom/

cd $XEN/
make clean
make dist KERNELS=$DOM0
make install KERNELS=$DOM0
depmod $DOM0_MODULES
mkinitrd -v -f /boot/initrd-$DOM0_MODULES.img $DOM0_MODULES \
	--builtin=pata_marvell \
    --builtin=ehci-hcd --builtin=ohci-hcd --builtin=uhci-hcd --builtin=ahci --builtin=ata_piix

exit 0