Xen Overview
Xen is a Virtual Machine Monitor (VMM) originally developed by the Systems Research Group of the University of Cambridge Computer Laboratory, as part of the UK-EPSRC funded XenoServers project . A Virtual Machine Monitor is a piece of software which manages several “virtual” computer systems which are all running on a single piece of hardware.
Xen is free software, and because of that, we’ve made it easy for customers to use so that you can split your dedicated host into multiple partitions, and use each one as a separate system.
Xen systems run a “hypervisor” which is invisible in normal operation, because this software starts a normal Linux kernel. We set the system up to run Debian GNU/Linux, and the first Operating System is known as the “domain 0” or “dom0”.
Once you have control over dom0, you are able to start further systems by carving up system resources such as memory and disc space.
This page shows you how to use a configured Xen host on the Bytemark network.
If your system was not delivered with Xen installed, you will need to re-image your machine before these instructions will work for you.
Important Xen files
Each guest (or virtual machine) has three important resources to set up:
- a configuration file all the information on the guest (host name, networking details and amount of memory);
- a disk image which the guest will see as its root filesystem; and
- a disk image which the guest will use for swap space.
With Bytemark’s tools, each configuration file is called /etc/xen/NAME.cfg, so if we had a guest called test.example.com we would create a configuration file called /etc/xen/test.example.com.cfg.
We create the root and swap files within a directory /home/xen/domains/test.example.com
The overall Xen configuration can be found in /etc/xen/xend-config.cfg which shouldn’t need to be changed.
Common Xen Tasks
From the domain 0 there are several common tasks you will wish to carry out. Each of actions is usually started by the xm command. This program communicates with the Xen control daemon (xend) to carry out the actions specified.
You can run xm --help for a complete list of commands, but we’ll summarise the important ones here.
Creating new guests
Before you can bootup a virtual machine you must first create it. The core Xen installation itself doesn’t really help you here – there are lots of ways to achieve this if you’re comfortable doing the setup manually.
To make the initial setup simple we’ve already installed a package called xen-tools upon your host whose main job is to assist with creation of new guests.
Read more about xen-tools and creating new systems
List Running Guests
If you wish to list running guests you may execute :
xm list
This will produce output such as:
root@mine:~# xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 675 2 r----- 32146.8
Here you can see that “Domain-0”, or the host system, is the only thing running.
Once you’ve started up a guest, or two, you’ll see output similar to this:
root@mine:~# xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 675 2 r----- 32149.1
builder.my.flat 21 64 1 -b---- 523.8
cfmaster.my.flat 22 64 1 -b---- 182.1
This output displays the name of each guest, their ID, amount of memory allocated to each one, and etc.
Start A Guest Running
As we’ve previously discussed each guest upon the host system will have a configuration file located within the directory /etc/xen, this will have a name such as test.example.com.cfg.
To start this domain running you may execute “xm create filename”, for example:
root@mine:~# xm create cfmaster.my.flat.cfg
Using config file "/etc/xen/cfmaster.my.flat.cfg".
Started domain cfmaster.my.flat
Here you can see that you’ve only specified the filename and the Xen system knew that it should be loaded from /etc/xen.
Serial Console Access
If you run into any problems with the network setup of your guests you can fix them by logging in using the serial console.
To connect to the console of a running guest run “xm console NAME”.
For example to connect to the console of the test.example.com guest you’d run:
xm console test.example.com
To exit the serial console you should press Ctrl+] – in the same way that you’d exit from a telnet session.
Shutdown A Running Guest
To shutdown a running guest you would run “xm shutdown name”. So to shutdown the guest with the name cfmaster.my.flat, for example, you’d run:
root@mine:~# xm shutdown cfmaster.my.flat
After a few seconds you should see the name removed from the list of running guests.
As a shortcut between shutting down a machine and starting it you can reboot it in one step with:
root@mine:~# xm reboot builder.my.flat
Advanced Xen Control
If you wish to allow other users to administer your Xen guests, for example if you wish to resell xen hosting you could consider setting up each user with a remote ssh login to your host.
When these remote users connected to your host system they would automatically be dropped into a simple shell which would allow them to control their guest – but not those instances belonging to other users.
Please see the xen-tools page for more information on how to achieve this.
Topics:
