Xen
Converted with HTML::WikiConverter::MediaWiki from my old phpwiki site
Install of Xen Source (paravirtualizer) on Debian Sarge
Install of Xen
I used the binary distribution of xen 2.0.7 altough I also tried to compile a custom kernel as I had question about hardware support which I didn't find in the pached kernel. I posted it on the xen-users ML, no answer yet.
To be documented (note are offline)
update grub's menu.lst and rename /lib/tls in /lib/tls.disabled as it is not natively supported by xen and need a real emulation which will reduced performance a lot (this step has to be done in all unpriviledged guest too (enforce it ?)
Xen topology
Xen uses a para-vitualisation hypervisor running in ring 0 (x86 CPU).
The kernel runs in ring1 and user-app in ring3.
Hardware management is done inside a privileged kernel named domain0 (guest OSes are called domainX).
Xen uses a xend daemon in dom0 to manage network, cpu, memory and export standard devices to the domX guest (generally eth0, a root fs and some swap space).
xend also manages bridging the real eth0 and sets up a xen-br0 device
xend is not running by default on dom0 at startup
Invoking
update-rc.d xend defaults 80
does the job as dmesg says
eth0: link up, 100Mbps, full-duplex, lpa 0x45E1 eth0: Promiscuous mode enabled. device eth0 entered promiscuous mode xen-br0: port 1(eth0) entering learning state xen-br0: topology change detected, propagating xen-br0: port 1(eth0) entering forwarding state
and
ns1:/home/skycode# xm list Name Id Mem(MB) CPU State Time(s) Console Domain-0 0 251 0 r---- 13.0
So domain0 is now running (in a small 4Go partition, the rest of the disk is left for LVM)
setting-up LVM for the hosts
apt-get install lvm2
Partitioning the free space left on the disk
ns1:/home/skycode# fdisk /dev/hda The number of cylinders for this disk is set to 9964. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/hda: 81.9 GB, 81964302336 bytes 255 heads, 63 sectors/track, 9964 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 1 486 3903763+ 83 Linux /dev/hda2 * 487 608 979965 82 Linux swap / Solaris Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (609-9964, default 609): Using default value 609 Last cylinder or +size or +sizeM or +sizeK (609-9964, default 9964): Using default value 9964 Command (m for help): p Disk /dev/hda: 81.9 GB, 81964302336 bytes 255 heads, 63 sectors/track, 9964 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 1 486 3903763+ 83 Linux /dev/hda2 * 487 608 979965 82 Linux swap / Solaris /dev/hda3 609 9964 75152070 83 Linux Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): 8e Changed system type of partition 3 to 8e (Linux LVM) Command (m for help): p Disk /dev/hda: 81.9 GB, 81964302336 bytes 255 heads, 63 sectors/track, 9964 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 1 486 3903763+ 83 Linux /dev/hda2 * 487 608 979965 82 Linux swap / Solaris /dev/hda3 609 9964 75152070 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table.
reboot :-)
Create physical volumes
pvcreate /dev/hda3</pre> add it to a volume groupvgcreate volg0 /dev/hda3 Volume group "volg0" successfully created
Create 2 partition (root and swap for the first test domain)
ns1:/home/skycode# lvcreate -L 2G -n test0root volg0 Logical volume "test0root" created ns1:/home/skycode# lvcreate -L 256M -n test0swap volg0 Logical volume "test0swap" created ns1:/home/skycode# mke2fs -j /dev/volg0/test0root mke2fs 1.37 (21-Mar-2005) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 262144 inodes, 524288 blocks 26214 blocks (5.00%) reserved for the super user First data block=0 16 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 38 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. ns1:/home/skycode# mkswap /dev/volg0/test0swap Setting up swapspace version 1, size = 268431 kB no label, UUID=451e4e02-5d9f-4524-922a-c7432e844b21 ns1:/home/skycode#
Install a minimal debian sarge with debootstrap and back-it up for futur installs
ns1:/home/skycode# debootstrap --arch i386 sarge /mnt/xen_install http://www.uk.debian.org/debian/ Lots of output ... ns1:/home/skycode# cd /mnt/xen_install/ ns1:/mnt/xen_install# mkdir /var/xen_images ns1:/mnt/xen_install# tar -jpcf /var/xen_images/debian-sarge-pre-config.tar.bz2 .
Now it's config time
fstab
ns1:/mnt/xen_install/etc# cat fstab # Fstab for virtual domain root is exported by dom0 as sda1 # And swap as sda2 # # Exxoss - brewed on March 24th 2006 /dev/sda1 / ext3 defaults 0 1 /dev/sda2 swap swap defaults 0 0 proc /proc proc defaults 0 0
hostname
ns1:/mnt/xen_install/etc# cat hostname test0
hosts
ns1:/mnt/xen_install/etc# cat hosts 127.0.0.1 localhost
Network interfaces
ns1:/mnt/xen_install/etc# cat network/interfaces # Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or # /usr/share/doc/ifupdown/examples for more information. # # Exxoss - brewed march 24th 2006 # virtual domain interface config file # dom0 export a NIC as eth0 # # Loopback device auto lo iface lo inet loopback # eth0 device auto eth0 iface eth0 inet static address 192.168.1.111 netmask 255.255.255.0 gateway 192.168.1.1
sources.list
ns1:/mnt/xen_install/etc# cat apt/sources.list #deb file:///cdrom/ sarge main deb http://ftp.debian.skynet.be/ftp/debian/ stable main contrib deb-src http://ftp.debian.skynet.be/ftp/debian/ stable main contrib deb http://security.debian.org/ stable/updates main contrib
lib/tls (again)
ns1:/mnt/xen_install/etc# cd .. ns1:/mnt/xen_install# mv lib/tls lib/tls.disabled umount /mnt/xen_install
Configure xen for the new dom
in /etc/xen/test0.conf
ns1:/etc/xen# cat /etc/xen/test0.conf
#
# Test Xen domU config file
#
name="test0"
memory=256
kernel="/boot/vmlinuz-2.6-xenU"
nics=1
disk=[%27phy%3Avolg0 'phy:volg0][%27phy%3Avolg0/test0root%2Csda1%2Cw%27%2C%20%27phy%3Avolg0 /test0root,sda1,w', 'phy:volg0]test0swap,sda2,w'[%27phy%3Avolg0/test0root%2Csda1%2Cw%27%2C%20%27phy%3Avolg0/test0swap%2Csda2%2Cw%27?action=create ?]
root="/dev/sda1 ro"
ns1:/etc/xen#
xm (xend ctl tool) commands
Create a new domain <pre>xm create /etc/xen/test0.conf -c</pre>
Logout from console to dom0 : Ctrl-]
list runing domains <pre> xm list </pre>
stop a runing domain <pre> xm shutdown domain </pre>
Tests
what happens if I try to allocate more meory to a domain than I have available
it fail rturning an error code (12)
set the cpu time limit
use cpu_weight in config file like cpu_weight=5