What is Xen
Xen is a virtual machine monitor (VMM) for x86-compatible computers. Xen can securely execute multiple virtual machines, each running its own OS, on a single physical system with close-to-native performance.
Xen in FC4
You have to install the following packages xen , kernel-xen0 and kernel-xenU.
xen is the hypervisor, kernel-xenO is the "main domain" and kernel-xenU are the user created domains Each user domain can have a different version of a kernel
After installation of xen and kernel-xenO-<version> your grub config will looks like this
title Fedora Core (2.6.11-1.1353_FC4xen0)
root (hd1,7)
kernel /xen.gz
module /vmlinuz-2.6.11-1.1353_FC4xen0 ro root=/dev/VolGroup00/LogVol01
module /initrd-2.6.11-1.1353_FC4xen0.img
the kernel /xen.gz is the hypervisor which controls the virtual machines.
The part vmlinuz-2.6.11-1.1353_FC4xen0 is domain0 and from here you can create user domains
when you reboot as above you will be in Domain0
When you issue the command service xend start it will start xen
With the command xm list you can see what domains are running
xm list
Name Id Mem(MB) CPU State Time(s) Console
Domain-0 0 256 0 r---- 554.8
base1 2 63 0 -b--- 92.4 9602
httpd 4 64 0 -b--- 16.5 9604
above you see 3 domains
Domain-O having 256Mb of memory and is my normal FC4 working area
I have also created 2 virtual domains base1 and a httpd server both using 64Mb each
btw " xm help " will give you more info
The user domains do not have any physical devices an example of ifconfig in domain0
eth0 Link encap:Ethernet HWaddr 00:30:BD:2A

6:E8
inet addr:192.168.1.130 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::230:bdff:fe2a:c6e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
<snipped>
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
<snipped>
vif2.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF
inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
<snipped>
vif4.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF
inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
<snipped>
xen-br0 Link encap:Ethernet HWaddr 00:30:BD:2A

6:E8
inet addr:192.168.1.130 Bcast:192.168.1.255 Mask:255.255.255.255
inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
<sniiped>
Above you see the xen-brO which is the interface between the physical
interface and the virtual interfaces vif 2.0 (domain 2 interface 0) and vif 4.0
Note the same IP addres and hardware address between eth0 and br0 but a difference of inet6 address
This is the ifconfig of vif 2.0
eth0 Link encap:Ethernet HWaddr AA:00:00:4B:42:F3
inet addr:192.168.1.112 Bcast:192.168.1.255 Mask:255.255.255.0
<snipped>
It has created an virtual hardware MAC address
Creation of a Base user domain
Let's first investigate the yum groupinstall
With fedora it is possible to install,update upgrade by groups
"yum grouplist will" show a list of groups for installalation created by fedora
yum grouplist
Setting up Group Process
Setting up repositories
jr 100% |=========================| 1.1 kB 00:00
Installed Groups:
Compatibility Arch Support
DNS Name Server
Mail Server
Text-based Internet
Available Groups:
Administration Tools
Authoring and Publishing
<snipped>
Our target is to install a Base system so let's have a look
yum groupinfo Base
Setting up Group Process
Setting up repositories
jr 100% |=========================| 1.1 kB 00:00
Group: Base
Required Groups:
Core
Dialup Networking Support
Mandatory Packages:
tmpwatch
traceroute
<snipped>
Default Packages:
openssh-clients
nss_db
acpid
nss_ldap
<snipped>
Optional Packages
netconfig
brltty
<snipped>
You can try this out in your current domain
Anyway to install the above base package is approx 180Mb and depending on your download speed this might take a while (I have a DL of 5 MB/s and it took me 30-45 minutes using a local repo site.
Option 1 use the repo site of a mirror
Option 2 create our own repo
I have downloaded FC4T3 and saved it to the hard disk I do my installl's from a hard drive as I don't have a DVD writer and my CD burner doesn't seem to be to good
Mounted the DVD iso as a loop the device and created myrepo.repo it could not find the repodata and as it was also not possible to write to the iso I created a directory where I installed all the rpm's.
with the command createrepo /directory/rpms I was able to create a repodata directory I still had a problem getting the groupinfo available.
After searching the internet I found I had to place comps.xml in the repodata and recreated "createrepo" and it worked It saved me a lot of time of waiting.
so in /etc/yum.repos.d
myrepo.repo
[myname]
name=Fedora Core Base
baseurl=file:///myname/Fedora/RPMS/
enabled=1
gpgcheck=0
For the time I dissabled the other repos.
I also disabled Selinux
Now on to creating a vitual user domain
I created a script as I tried before several times and typo errors etc
mkdir -F -j /xen/base
dd if=/dev/zero of=/xen/base.img bs=1M count=1 seek=1024
mkfs.ext3 /xen/base.img
mount -o loop /xen/base.img /xen/base
for i in console null zero ; do MAKEDEV -d /xen/base -x $i ; done
yum --installroot=/xen/base -y groupinstall Base
I ignored any errors and hoped for the best
Created also an fstab file and copied to /mnt/etc
fstab
/dev/sda1 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
We also need to create a config file in /etc/xen Domain0
kernel ="/boot/vmlinuz-<version>FC4xenU"
memory = 64
name = "myxen"
nics = 1
disk = ['file:/xen/base.img,sda1,w']
root = "/dev/sda1 ro"
and save as myxen
Check in /mnt/etc/selinux the config file and look for the line
SELINUX=Permissive
This is my file.
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=Permissive
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
umount /mnt/xen/base.
So ready to start a virtual machine
Create some memory in Domain0 with
xm balloon O 256 "this reserves 256MB for domain 0
xm create -c myxen
It will now create a user domain and with the -c option you should be able to login as root.
Once logged in you willl have a minimal system
If you have a dhcp server do dhclient eth0 and you should get a IP address from your dhcp server.
From within your user domain you do not have direct access to your hardware.
The next challenge was to create a httpd server.
First you can copy xen/base.img to xen/httpd.img
copy or create myhttp
kernel ="/boot/vmlinuz-<version>FC4xenU"
memory = 64
name = "myhttp"
nics = 1
disk = ['file:/xen/httpd.img,sda1,w']
root = "/dev/sda1 ro"
I am currently not able to see domainO hard disks in my user domain so I created a FTP server in domain0 so that I can use yum in my user domain to install packages
I used vsftp all I did was pointing anon_root=repodirectory
I created a user domain xm create -c myhttp and login
Go in User domain to etc/yum.repos.d I dissabled all the fedora.repos and created
myrepo.repo
[jr]
name=Fedora Core Base
baseurl=ftp://192.168.1.130//Fedora/RPMS/
enabled=1
gpgcheck=0
If you have connectivity with your ftp server you should be able to install any package you like
So to install a http web server
yum groupinstall "Web Server"
and this install the appache web server
Not all the times it went smoothly a lot of trying and errors but it is fun!
References:
http://www.fedoraproject.org/wiki/FedoraXenQuickstart
http://www.cl.cam.ac.uk/Research/SRG/netos/xen/
http://www-128.ibm.com/developerwork...library/l-xen/