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.
- Xen domain
- One Xen instance. It can be privileged (dom0) or not (domU)
- Privileged Xen domain. Is used as Xen host manager. Has full access to hardware devices.
- Unprivileged Xen domain. Also called "guest" or "VM" for Virtual Machine. By default, does not have any direct access to hardware devices.
- Distributed Redundant Block Device. Used to replicate Hard disks through network. Heavily used in High Availability environments.
- Logical Volume manager. Abstraction level for disks and partitions. Makes disk managment much more easy. Can also provide snapshots features.
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.
- 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.
- 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.
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.
If you don't know DRBD, you can read: DRBD: Distributed Replicated Block Device
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:
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:
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
xm restart xps-101
- Soft stop
xm shutdown xps-101
- Hard stop
xm destroy xps-101
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
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.
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
Sources and references
- GNU/Debian Linux
Documentation and Howto
- Dom0 Lenny kernel
- UDEV inside DomU
- HVM support
- Access domU LVM partition from within dom0
- DomU brutal test
- Mirror creation
- Keymap setting for VNC
Windows as Xen domU