How to install Xen 3.0 on Slackware 10.2 as dom0
I wiped a partition and installed Slackware 10.2 from scratch. I set my eth0 interface to 192.168.0.5 as I normally do. My gateway, as always, was 192.168.0.1 to myfirewall. Hostname = mutt.
Getting and installing 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.
In my case, the kernel created for dom0, did NOT support my Davicom card, so I had to re-compile this kernel. There's a trick to this.
You need to change directory into your xen-unstable/linux-2.6.12-xen0 directory and run make ARCH=xen menuconfig instead of the normal 'make menuconfig'.
To compile the kernels, you do make on exit, then step up one directory level and do make install.
Installing GRUB
You need to install GRUB, since Slackware 10.2, by default, doesn't use GRUB. You have to use CVS for this, as follows :-
# cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/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. Instead of doing all that strange downloading of a filesystem stuff, I just rebooted and 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
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".
Installing VNC
Now, you can, at this point, NOT install VNC, and instead, just work off the command line. But this is a new century, right? So we're doing to do the GUI thing, ok?
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 (inside the VM) 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
A word of explanation interjected here
How does the host domain, dom0, communicate with the guest domain, domU?
The answer is "over an internal network". Xen sets up one virtual interface on the host and another on the guest. They both belong to the same subnet, which, normally, is not part of the external network. I found that, by default, the host interface was set to 10.0.<something>.128 and the guest interface was set to 10.0.<something>.1
Now, initially, the <something> would be 1 and every time I created a new domain, it would be incremented by 1 to 2, 3, 4, 5 etc. Tricky, huh? I suppose the Xen people expect you to keep creating new domains all day.
The problem was 'how do I set the guest interface's IP address?' Well, the story is, when you boot the guest domain, you end up in a kind of shell with a login prompt and everything. So you can just login and run your normal sequence of networking setup steps.
The command sequence is usually something like :-
ifconfig eth0 10.0.1.1 netmask 255.255.255.0 up route add default gw 10.0.1.128
Then, you ping 10.0.1.128 to check connectivity from the guest to the host.
Fine. And this works. But it gets old real fast. So I looked for a better way. The answer, of course, is our old friend, DHCP. And the Xen people have set up things to help us. The LiveCD works wonderfully. So I wanted that slick Xen thingy, too.
It took some work. The Xen scripts do not take Slackware into consideration, so we have to be brave and dig around. I tried not messing things up too much, but obviously, I haven't been to Cambridge University, so I did it in Trini-style.
Somebody with more understanding can explain how the Xen scripts work, but I was just looking to get them to work for me. In the end, I had to modify four scripts
/etc/xen/xend-config.sxp /etc/xen/scripts/network-nat /etc/xen/scripts/vif-nat /etc/xen/scripts/xen-network-common.sh
Networking Changes
If you are planning on using Xen's default bridged networking setup in Slackware, you will need to change a single line in /etc/xen/xend-config.sxp as follows. Find the line that reads:
(network-script network-bridge)
Change this line to:
(network-script 'network-bridge netdev=eth0')
In this change we have specified that we want to use eth0 as the network interface, rather than allowing the script to fail to find this value automatically. We can see the symptoms of this problem in the output of the following command: # sh /etc/xen/scripts/network-bridge start
This generates the following output:
Device "1" does not exist. Device "1" does not exist. Device "1" does not exist. Cannot find device "1" SIOCGIFFLAGS: No such device
Fortunately, it's a simple fix, as seen above.
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
#===================================================
Ending comments
I wanted that cool LiveCD thing where the guest domain pops out in your face. I never got there. I spent a lot of time trying to get it to work.
One morning, after breakfast, it hit me. The Xen people (tricky lads) were using something in the background to communicate between the host and the guest. They have some kind of virtual filesystem or something called a 'xenstore'. I could never find where the xenstore was hidden, but I did find the two scripts which caused the guest domain to pop out like that.
They are vnc-advertiser and vnc-watcher.py, in case anyone is interested. But they are not absolutely essential to getting Xen working.
Off to sleep now.
