Introduction
Xen is one of the most used opensource virtualization system. Firts releases were only able to virtualize open operating systems because some kernel modifications were needed.
Nowadays, recent processors embbed features which allow to virtualize more operating system without any kernel modifications.
Let's see how to install, configure and get started with Xen under Debian GNU/Linux Lenny with amazing features like DRBD and LVM.
Glossary
- Xen domain
- One Xen instance. It can be privileged (dom0) or not (domU)
- Dom0
- Privileged Xen domain. Is used as Xen host manager. Has full access to hardware devices.
- DomU
- Unprivileged Xen domain. Also called "guest" or "VM" for Virtual Machine. By default, does not have any direct access to hardware devices.
- DRBD
- Distributed Redundant Block Device. Used to replicate Hard disks through network. Heavily used in High Availability environments.
- LVM
- Logical Volume manager. Abstraction level for disks and partitions. Makes disk managment much more easy. Can also provide snapshots features.
Storage choice
You have multiple choice for storage
- Image file
- Hard disk is "virtualized" as file, just like VMWare does. Quite simple to setup and use, it sometimes suffer some performances issues and does not allow live migration, except with centralized storage like NFS.
- NFS
- Usefull with image files, you must have a strong network to get decent performances. If you do not plan to use live migration, NFS is not the best solution to use.
- LVM
- Much better solution, especially with DRBD or LVM mirorring features. You'll get local storage performances with much more flexibility.
- LVM + DRBD
- LVM flexibility with DRBD replication feature. A must have ! Of course, to use this, you'll need at least 2 servers.
As I have 2 servers for my tests, I choose to use LVM+DRBD. Configured in dual primary mode, DRBD gives you the ability to perform live migration on a per VM basis. Usefull when you want to spread your VMs accross you Xen hosts.
Our system will behave as follow:
- Each virtual machine will be installed on a DRBD ressource based on LVM. DomU itself can be installed upon LVM or not, it does not matter. DRBD ressource will be seen as an harddisk from domU.
- Each Logical Volume will be associated to a DRBD ressource to allow replication. There will be a DRBD ressource for each VMs.
- Virtual machines will be spreaded across Xen nodes. Beware you have to keep CPU and memory ressource on each node to be able to run all VMs on one node when you have to perform a maintenance on the ohter one.
LVM configuration
If you do not know LVM, you can read LVM: Logical Volume Manager
You first have to create a partition and prepare it as Pfysical Volume. For example, on my dom0, I create 2 PVs:
SystemPV which is 50GB big. It will be used for dom0 system instlalation.XenHostingPV which will use to remaining disk space. It will host DomU.
DRBD configuration
If you don't know DRBD, you can read: DRBD: Distributed Replicated Block Device
Xen installation
Debian GNU/Linux Lenny ships Xen in verison 3.2. Xen installation is as easy as executing:
Once kernel is installed, you can reboot your node. After reboot, just check that Xen hypervisor is started:
Network configuration
Like storage, Xen can deal with various network configuration:
- Bridged network
- Easiest solution, each VM has its own IP address. Sometimes forbidden by some hosting companies because having multiple MAC adresses per interface is not supported for security reasons (that avoid MAC adress spoofing).
- Routed network
- Dom0 acts as router. Each VM still has its own IP address, but MAC adresses won't be broadcasted any more outside of Xen host.
- Natted network
- Dom0 will act as gateway for domU and will translate IP addresses. Reserved for very specific use because domU won't have direct access to the network.
We'll use bridged network solution. Let's activate it:
Then:
Finally:
If you can see peth0 interface, you're done. It's a veray classic bridged network, there's no surprise in there.
HVM domU configuration
I'll only cover fully virtualized VM (or HVM) confiugration.
This allows you to get "real" independent servers. As an example, this configuration is required to install a Windows based DomU.
Each VM must have its own configuration file.
Once you're done with confiiguration, you can start your domU and install it as you would do with a physical server.
HVM DomU control
Controlling a domU is quite simple. There's not so much operation available:
- Create / Start
- Normal power off / Hard power off (Destroy)
- Live migration
domU creation
Power off
- Restart
xm restart xps-101- Soft stop
xm shutdown xps-101- Hard stop
xm destroy xps-101
Migration
For live migration to work, you need more informations. As an exemple, you will need remote dom0 peer.
Xen must also be configured to communicate with its peer. For this, you need to adapt /etc/xen/xend-config-xenapi.sxp file.
You also have to restart xend service. Then, use following command to live migrate your domU:
Where 192.168.0.2 is remote Xen dom0 peer.
Maintenance
Sometime, you could want to access you domU without using network (if for example you just made a mistake with firewall :) ).
To leave console mode, just use CTRL+ALTGr+]
Sources and references
Official websites
- Xen
-
- http://www.xen.org/
- DRBD
-
- http://www.drbd.org/
- GNU/Debian Linux
-
- http://www.debian.org/
Documentation and Howto
- Xen
-
- http://www.howtoforge.com/debian_etch_xen_3.1
- http://www.labo-linux.org/articles-fr/premiere-approche-de-xen/installation-de-xen
- http://www.xen-tools.org/software/xen-tools/examples.html
- http://wiki.debian.org/Xen
- https://asi.insa-rouen.fr/asipedia/index.php/Xen
- https://help.ubuntu.com/community/Xen
- http://www.howtoforge.com/debian_etch_xen_from_debian_repository
- http://howto.landure.fr/gnu-linux/debian-4-0-etch/installer-et-configurer-xen-sur-debian-4-0-etch
- http://www.hostinggeek.com/
- http://www.projet-plume.org/fiche/xen
- http://virtualization4xceptn.wordpress.com/2008/09/15/xen-how-to-define-the-boot-order-for-hvm-in-vmcfg/
- http://etbe.coker.com.au/2007/07/27/a-support-guide-to-xen/
- LVM
-
- http://www.morot.fr/spip.php?article35
- http://linux.developpez.com/lvm/#L4.2
- http://clx.anet.fr/spip/article.php3?id_article=237
- DRBD
-
- http://www.drbd.org/users-guide/
Some tips
- Dom0 Lenny kernel
-
- http://lists.debian.org/debian-devel/2008/07/msg00312.html
- http://kernel-archive.buildserver.net/debian-kernel/waldi/xen-extra/pool/main/l/linux-2.6/
- UDEV inside DomU
-
- http://codewut.de/xen-on-32bit-os-with-8gb-ram
- http://lists.xensource.com/archives/html/xen-users/2006-09/msg00284.html
- HVM support
-
- http://wiki.xensource.com/xenwiki/HVM_Compatible_Processors
Troubleshooting
- Access domU LVM partition from within dom0
-
- http://blogs.simc.be/simc/index.php/post/2009/01/22/Kpartx-pour-aller-un-peut-plus-loin-avec-LVM
- http://cedric-tintanet.developpez.com/tutoriels/linux/sauvegarde-virt/
- DomU brutal test
-
- http://www.cyberciti.biz/faq/understanding-bash-fork-bomb/
- Mirror creation
-
- http://smhteam.info/wiki/index.linux.php5?wiki=CreerUnMirroirDebianLocal
- http://www.debian.org/mirror/ftpmirror.fr.html
- http://www.debian.org/mirror/list-full#FR
- http://howto.landure.fr/gnu-linux/ubuntu-edgy-eft/developpement-et-serveurs/creation-dun-mirroir-ubuntu-local-a-laide-de-apt-mirror
- http://doc.ubuntu-fr.org/tutoriel/creer_un_miroir_de_depot_local
- Keymap setting for VNC
-
- http://linux.derkeiler.com/Mailing-Lists/Debian/2007-11/msg01128.html
Windows as Xen domU
- http://blog.sietch-tabr.com/index.php/post/2007/09/24/faire-tourner-Windows-sur-Xen
- http://www.virtuatopia.com/index.php/Installing_and_Running_Windows_XP_or_Vista_as_a_Xen_HVM_domainU_Guest
- http://www.winattended.com/finalisationwin2003.php
- http://blogcastrepository.com/blogs/benoits/
- http://sysadmin.wikia.com/wiki/Microsoft_Windows
- http://oss.netfarm.it/guides/pxe.php
- http://oss.netfarm.it/guides/ris-linux.php
- http://oss.netfarm.it/guides/
- http://www.gentilkiwi.com/divers-s27-t-embellissement-de-l-interface-de-demarrage.htm
- http://www.gentilkiwi.com/divers-s26-t-windows-pe-2.0--vista--sur-pxe.htm
- http://www.gentilkiwi.com/documentations-s11-t-pxe.htm#tftp
- http://www.virtuatopia.com/index.php/Building_a_Xen_Virtual_Guest_Filesystem_on_a_Physical_Disk_Partition_(Cloning_Host_System)
- http://www.nasgo.altervista.org/Procedure.html
- http://www.promodus.net/linuxris
- http://www.nu2.nu/pebuilder/#download
