Last weekend, when I was
struggling to understand how to get Xen to work, I would have loved to
have found a document detailling the steps. So, for anybody who might
be struggling with the same problem, here's my HOWTO. It may not
accurate, but it worked for me.
How to install Xen 3.0
Download the tarball from the Xen site
wget http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/xen-3.0.0-src.tgz
make a directory somewhere and untar the tarball into it. You will
get a directory called xen-unstable.
change directory into xen-unstable
run make world
this will download a kernel from www.kernel.org and compile
everything you need. get a coffee or take a nap. The kernel took 3.5
hours to download at home over dialup.
When it's finished, run make install
This installs the new kernels (there are two) into /boot. Don't
worry... it doesn't overwrite the old one.
Installing GRUB
You need to install GRUB, if it isn't already on your machine. You
have to use CVS for this, as follows :-
# cvs -z3
-d:pserver:anonymous@xxxxxxxxxxxxxx:/sources/grub co grub
This eventually downloads everything into a directory called grub.
Change directory to grub and run
# ./configure && make && make install
This puts GRUB into /usr/local/*sbin*.
Then, as root, run :-
# grub-install
It may give an error. Just do it again.
You need to make a menu entry into /boot/grub/menu.lst
to boot Xen.
I used :-
title Xen root (hd0,4) kernel /boot/xen.gz dom0_mem=262144 module /boot/vmlinuz-2.6.12-xen0 root=/dev/hda5 ro
Then, reboot into your new Xen setup. You should be running a kernel
which ends in -xen0. Check with 'uname -a'.
Setting up a guest domain
The next thing is to setup the domain you will run as a guest under
your master domain. I installed Zenwalk 2.01 on /dev/hda3 and made sure
it was working properly first, before attempting to use it as a guest.
To set up a guest domain, there are a series of steps.
Create a config file. I used /etc/xen/mydom, which contains :-
kernel = "/boot/vmlinuz-2.6.12.6-xenU" memory = 128 name = "zenwalk" vif = [ 'mac=aa:00:00:00:00:11'] disk = [ 'phy:hda3,hda3,w' ] dhcp = "dhcp" root = "/dev/hda3 ro"
extra = "4"
This means :-
boot off the kernel in /boot/vmlinuz-2.6.12.6-zenU
assign 128MB of RAM to this guest
assign hostname = "zenwalk" ? I think, perhaps it is domain-name
assign a mac address of aa:00:00:00:00:11 to the virtual interface eth0
in the domain
map the partition /dev/hda3 to the virtual machine as /dev/hda3 and
allow writing to it
use DHCP in the virtual machine (you still have to set up DHCP inside
the virtual machine anyhow - PITA)
use /dev/hda3 as the root partition
boot to runlevel 4 in the virtual machine
The next thing to do, is to mount the partition where I installed
Zenwalk on /mnt/hd. Then,
mount /dev/hda3 /mnt/hd cd /mnt/hd/lib/modules cp -av /lib/modules/2.6.12.6-xenU/* . cd /mnt/hd/lib mv tls tls.disabled
Installing VNC
Then, download and untar the latest free version of VNC from http://www.realvnc.com/.
You can't install it just yet, you need to be inside the virtual
machine to install it.
Once you DO have VNC installed, you need to edit /mnt/hd/etc/X11/gdm/gdm.conf
to get GDM to start up Xvnc automatically when the VM boots. Add a
stanza for VNC as follows :-
[server-VNC] name=VNC server command=/usr/bin/Xvnc -SecurityTypes None -geometry 800x600 -depth 24 flexible=true
Change the stanza [servers] to :-
[servers] 0=VNC
Fiddling with the scripts
Ok, now because this is Slackware and not Debian and not
RedHat? or Fedora or
Centos, you need to "fiddle" with some of the scripts they give you.
To begin with, I couldn't get the default setup to work at all.
I needed to edit /etc/xen/xend-config.sxp to use the NAT setup instead
of the bridge setup. To do this, you need to comment the lines
(network-script network-bridge) (vif-script vif-bridge)
and un-comment the lines
(network-script network-nat) (vif-script vif-nat)
In /etc/xen/scripts/network-nat and vif-nat,
change dhcp=${dhcp:-no} to dhcp=${dhcp:-yes}.
Also, in the function dhcp_start(), I added
/usr/sbin/dhcpd
just before the line
"$dhcpd_init_file" restart
This was the only way I could get it to start DHCPD automatically.
To get Zenwalk to use DHCP, edit /mnt/hd/etc/rc.d/rc.inet1.conf
and change the line '*USE_DHCP[0]="no"*' to '*USE_DHCP[0]="yes"*'.
I also had to edit /etc/xen/scripts/xen-network-common.sh
because it didn't work with Slackware. This was critical so I'm
including the whole script.
# # Copyright (c) 2005 XenSource Ltd. # # This library is free software; you can redistribute it and/or # modify it under the terms of version 2.1 of the GNU Lesser General Public # License as published by the Free Software Foundation.
# # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details.
# # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# On SuSE it is necessary to run a command before transfering addresses and # routes from the physical interface to the virtual. This command creates a # variable $HWD_CONFIG_0 that specifies the appropriate configuration for
# ifup.
# Gentoo doesn't have ifup/ifdown, so we define appropriate alternatives.
# Other platforms just use ifup / ifdown directly.
## # preiftransfer # # @param $1 The current name for the physical device, which is also the name
# that the virtual device will take once the physical device has # been renamed.
if [ -e /etc/SuSE-release ] then preiftransfer() { eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- $1`
} ifup() { /sbin/ifup ${HWD_CONFIG_0} $1 } elif ! which ifup >&/dev/null then if [ -e /etc/conf.d/net ] then preiftransfer() { true } ifup()
{ /etc/init.d/net.$1 start } ifdown() { /etc/init.d/net.$1 stop } else
if [ -e /etc/slackware-version ] then preiftransfer() { true
} ifup() { true } ifdown() { true } else
logger -p "daemon.crit" -- \ "You don't have ifup and don't seem to be running Gentoo either!"
exit 1 fi fi else preiftransfer() { true } fi
first_file() { t="$1" shift for file in $@ do if [ "$t" "$file" ]
then echo "$file" return fi done }
find_dhcpd_conf_file() { first_file -f /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf }
find_dhcpd_init_file() {
first_file -x /etc/init.d/{dhcp3-server,dhcp,dhcpd} }
I think that was all the fiddling I had to do. Mind you, it took me
a good week to get this to work. I'm just slow, I guess.
Extra scripts I wrote
I wrote a script to help me manage the domain.
#!/bin/sh # # xmctl # # Richard Hamel-Smith - Mon Jan 16 16:40:07 AST 2006 #=================================================== pause() { echo -e "press to continue \c" read dummy
} while : do clear brctl show xm list echo -e " XM Menu ======= 1. create mydom 2. destroy mydom 3. connect to mydom 4. most /var/log/messages
5. most /var/log/debug 6. most /var/log/syslog q. quit
opt : \c" read OPT case $OPT in 1) killall dhcpd xm create mydom -c ;; 2) xm destroy zenwalk ;;
3) xm unpause zenwalk ; xm console zenwalk ;; 4) most /var/log/messages ;; 5) most /var/log/debug ;; 6) most /var/log/syslog ;; *) exit ;; esac done #===================================================
I wrote another script to launch vncviewer with the correct IP
address, which keeps changing each time you create a new domain.
#!/bin/sh # # vnc - calls vncviewer with the correct IP address # # Richard Hamel-Smith - Fri Jan 20 10:34:39 AST 2006 #=================================================== addr="` tail -1 /etc/dhcpd.conf |\
awk -F';' '{ print $2 }' |\ awk '{ print $2 }'`" echo $addr vncviewer $addr #===================================================
_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users
|