Xen

INSTALLATION

root@serv1:~# apt-get install linux-image-2.6.26-2-xen-686 xen-hypervisor-3.2-1-i386 \
xen-tools xen-linux-system-2.6.26-2-xen-686 linux-headers-2.6.26-2-xen-686 libc6-xen bridge-utils

add the following line to /etc/modules

loop max_loop=64

Reboot the server and start the hypervisor from the boot menu (Xen 3.2-1-i386 / Debian GNU/Linux, kernel 2.6.26-2-xen-686)

CONFIGURATION

Edit /etc/xen/xend-config.xsp

#fundamental 
(network-script network-bridge)   
(vif-script vif-bridge) 
  
#not sure if fundamental 
(dom0-min-mem 196) 
(dom0-cpus 0) 
(vncpasswd '') 

File /etc/xen/xen-tools.conf is not really useful for us at the moment, except maybe for the RAM (memory) dimension. In general, default options are indicated in that file (id-est options valid for any DomU created by xen-tools).

Add:

extra = 'xencons=tty1'

to

/etc/xen-tools/xm.tmpl

 

CREATION OF VIRTUAL MACHINES

Method 2: Use of xen-tools

This method is been used until now to create 6 virtual machines (DomUs?): Debian Lenny, Ubuntu Jaunty, Centos5, Fedora11, Slackware13 and Windows XP. The local network dhcp-server is configured to assign an IP address based on the VM MAC address. The dhcp-server can be the one of the ltsp server (id est the main VDD server) (see LTSP how-to section). Adjust MAC address according to your choices.

Debian Lenny DomU
root@serv1:~# cd /etc/xen-tools/partitions.d
root@serv1:/etc/xen-tools/partitions.d# nano lennyvm
[root]
size=5G
type=ext3
mountpoint=/
options=sync,errors=remount-ro

[swap]
size=1G
type=swap

[home]
size=6G
type=ext3
mountpoint=/home
options=nodev,nosuid

At this point we can create the DomU using lvm devices in "serv1" volume group

root@serv1:~# xen-create-image --lvm=serv1 --hostname=lennyvm --mac=00:16:3E:5F:07:10 --dhcp --dist=lenny \
--role=udev --passwd --partitions=lennyvm
Ubuntu Jaunty DomU

The partition file is the same as for the Lenny DomU. So you can just copy it in a file named jauntyvm and store it in the same folder. Before creating the DomU it has been necessary to do the following:

root@serv1:~# ln -s /usr/lib/xen-tools/edgy.d /usr/lib/xen-tools/jaunty.d
root@serv1:~# ln -s /usr/share/debootstrap/scripts/edgy /usr/share/debootstrap/scripts/jaunty

At this point we can create the DomU using lvm devices in "serv1" volume group

root@serv1:~# xen-create-image --lvm=serv1 --hostname=jauntyvm --mac=00:16:3E:5F:07:11 --dhcp --dist=jaunty \
--role=udev --passwd --partitions=jauntyvm
Centos 5 DomU

The partition file is again the same as for the Lenny DomU. Before to create the DomU it has been necessary to add some packages to the default list. So edit /etc/rinse/centos5-packages and add the following lines

nss 
nspr 
python-iniparse
passwd

At this point we can create the DomU using lvm devices in "serv1" volume group

root@serv1:~# xen-create-image --lvm=serv1 --install-method=rinse --dist=centos-5 --hostname=centos5vm \
--mac=00:16:3E:5F:07:12 --dhcp --passwd --partitions=centos5vm
Fedora 11 DomU

For this VM we followed a slightly different method. Beginnig from here http://doc.cheramy.name/xen_tools_installation_fedora_11_domu and here http://www.stacklet.com/downloads/images/fedora/11, we built a tar archive with a tuned fedora installation and then used "tar" as the install-method option of xen-create-image. So you can get our tar archive and then launch the xen-create-image command, just as like in the following. Be aware to modify the $PATH according to where you stored the tar archive. Usual content for fedora11vm partitions file.

root@serv1:~# cd /usr/lib/xen-tools
root@serv1:~# ln -s fedora-core-6.d fedora-11.d
root@serv1:~# wget http://www.vdd-project.org/fedora/fedora11_mod.tar
root@serv1:~# xen-create-image --force --lvm=serv1 --install-method=tar --install-source=$PATH/fedora11_mod.tar \
--dist=fedora-core-11 --hostname=fedora11vm --mac=00:16:3E:5F:07:13 --dhcp --partitions=fedora11vm --passwd

Still we have some working issues on this DomU ...

Slackware 13 DomU

For this VM too, we followed a similar method as for fedora, this time beginning from here http://www.stacklet.com/downloads/images/slackware/13.0 and then modifying the downloaded archive to tune the installation. Usual content for slackware13vm partitions file and same warning as above about modifying the $PATH.

root@serv1:~# wget http://www.vdd-project.org/slackware/slackware13_mod.tar
root@serv1:~# xen-create-image --force --lvm=serv1 --install-method=tar --install-source=$PATH/slackware13_mod.tar \
--hostname=slackware13vm --mac=00:16:3E:5F:07:16 --dhcp --partitions=slackware13vm
Windows XP DomU

As for building a Windows XP VM in XEN, stuff is somewhat different, above all because you need to use a different build method (linux kernel obviously doesn't fit for windows!).

In building Windows XP DomU we referred to some useful links. Take a look at them to get some background informations about "hvm" and "ioemu". http://www.ezunix.org/index.php?title=Windows_XP_in_XEN http://www.valent-blog.eu/2008/01/13/full-virtualization-di-windows-con-xen/ http://wiki.openlab-dist.org/index.php/Macchine_virtuali_Windows_su_XEN http://lists.xensource.com/archives/html/xen-users/2006-06/msg00599.html http://mediakey.dk/~cc/howto-install-windows-xp-vista-on-xen/

Here are some useful "warnings" about Debian Lenny Xen and "hvm": http://old.nabble.com/xen,debian-lenny-and-hvm(winxp)-td21033712.html

Requirements are: - a licensed and working Windows XP Pro distribution (either in CD or .iso format) (be aware that installing a Microsoft Windows "virtual" machine legally requires the same license needed for a "real" one) - a CPU with Intel's VM or AMD's AMD-V technology (a xm dmesg | grep VMX in command line will tell you if your CPU is supporting that)

FILE .CFG FOR LAUNCHING DOMU

The above commands install the DomUs? on "serv1" volume group logical volumes and create a .cfg file for any DomU for launching it.

As an example, the following is the resulting .cfg files for Lenny DomU. The other files are very similar to this, except for the Windows XP DomU one (see above, "Windows XP DomU").

Debian Lenny DomU .cfg file
root@serv1:~# cat /etc/xen/lennyvm.cfg
#
# Configuration file for the Xen instance lennyvm, created
# by xen-tools 3.9 
#

#
#  Kernel + memory size
#
kernel      = '/boot/vmlinuz-2.6.26-2-xen-686'
ramdisk     = '/boot/initrd.img-2.6.26-2-xen-686'
memory      = '512'

#
#  Disk device(s).
#
root        = '/dev/sda2 ro'
disk        = [
	       'phy:/dev/serv1/lennyvm-swap,sda1,w',
               'phy:/dev/serv1/lennyvm-root,sda2,w',
               'phy:/dev/serv1/lennyvm-home,sda3,w',
              ]


#
#  Hostname
#
name        = 'lennyvm'

#
#  Networking
#
dhcp        = 'dhcp'
vif         = [ 'mac=00:16:3E:5F:07:10' ]

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'
extra = 'xencons=tty1'

With the following command we launch the DomU and access its console (with the -c flag).

root@serv1:~# xm create /etc/xen/lennyvm.cfg -c

Once the DomU has been launched one can access to it both by ssh and by xen console

root@serv1:~# ssh lennyvm
root@serv1:~# xm console lennyvm

To see the status of the DomUs? use:

root@serv1:~# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  6576     8     r-----   1181.0
centos5vm                                    1   512     1     -b----     34.1
jauntyvm                                     2   512     1     -b----    270.5
lennyvm                                      3   512     1     -b----    119.2

Once accessed a DomU by xm console $DomU, use the combination ctrl + ] to return to the Dom0 prompt console.

Other useful xm commands are:

xm shutdown $ID or $DomU to shutdown a DomU xm reboot $ID or $DomU to reboot a DomU xm destroy $ID or $DomU to force the shutdown of a DomU

VIRTUAL MACHINE TUNING

Some tuning (both in command line and in GUI environment) has been necessary on DomUs? once they have been created. Here some fundamental tuning in command line env is outlined. Even if not specified, always remember to add one or more normal user(s) to system, with adduser $user, and to modify its groups membership with adduser or usermod (see the man pages for how to use those commands).

Debian Lenny DomU tuning

Add the following line to /etc/apt/sources.list

deb http://www.debian-multimedia.org lenny main 

Then update and upgrade the system, install missing packages (is obviously at your choice) and configure locales (in these examples locales are all for Italy):

root@lennyvm:~# apt-get install debian-multimedia-keyring
root@lennyvm:~# apt-get update
root@lennyvm:~# apt-get upgrade
root@lennyvm:~# apt-get install rcconf nano hal ntpdate
root@lennyvm:~# apt-get install gnome-desktop-environment kde kde-i18n-it xfce
root@lennyvm:~# apt-get install iceweasel icedove iceweasel-l10n-it icedove-l10n-it
root@lennyvm:~# dpkg-reconfigure tzdata
Ubuntu Jaunty DomU tuning

Update and upgrade the system, install missing packages and configure locales:

root@jauntyvm:~# apt-get install rcconf nano hal ntpdate
root@jauntyvm:~# apt-get install gnome-desktop-environment kde kde-i18n-it
root@jauntyvm:~# apt-get install firefox firefox-3.5-gnome-support human-theme language-selector \
language-pack-gnome-it language-selector-qt root@jauntyvm:~# apt-get install xfce4 xubuntu-default-settings usplash-theme-ubuntu root@jauntyvm:~# dpkg-reconfigure tzdata
Centos 5 DomU and Fedora 11 DomU tuning

Use the yum package manager to add desired application. In particular install Gnome, KDE, XFCE and X Window meta package using the yum grouplist and yum groupinstall utilities. Configure local time with tzselect.

Slackware 13 DomU tuning