Linux had always lacked a Open Source virtualisation technology in the same league as Solaris containers or commercial product like Vmware. That was until Xen came into the picture. Xen is an open source virtual machine monitor for x86 that supports execution of multiple guest operating systems.
Xen is released under the GPL and can easily be used to run virtually, OSes as diverse as different Linux distributions, BSD's and even windowsXP (though windows port is not available because of licensing restrictions). Virtualisation technologies are nothing new, what with Vmware, Usermode Linux, Win4Lin and others available. But Xen is relevant here because of the support for it from Redhat, GPL-ed licence and also its active development.
Recently, I downloaded the Xen Live CD ISO image (503 MB) from their website and burned it on to a CD in order to give it a trial run. What follows below are my experiences in trying out this very promising virtualisation technology.
The Xen Live CD comes with two images, them being :
Debian Etch and CentOS 4.1 . When I booted using the Live CD, I was presented with the GRUB boot loader which gave me a choice of booting two OSes. Them being Debian Etch and CentOS 4.1. I selected the Debian Etch and the booting proceeded without any problem. It took around 3 minutes to present the GUI login screen. Xen live CD uses GDM as the display manager and loads the Xfce desktop.
When the gdm (Gnome display manager) was fully loaded, you are presented with the login screen where you are prompted to log in as user root and password xensource. Once you are logged in, you are presented with two open applications - one an Xterminal and another giving a real time data of the virtual machine status (see figure below).
Next I decided to create a virtual machine for the CentOS Linux distribution in side the Debian etch distribution. For achieving this, you have a very user friendly command line utility called xm. I created the CentOS image as follows:
# xm create -c /root/centos-conf name=centos_1
It gave an error saying that it couldn't find enough memory to load CentOS and that it needed atleast 96 MB for the same when there was only 17 MB available. The machine on which I tested Xen is a Pentium IV 256 MB RAM machine. At this point I realised that almost all the memory on my machine was allocated to Debian Etch OS.
I figured out that one can reduce amount of memory allocated to the virtual OSes by using the same xm utility. For that you have to find the domain id of the virtual OS whose memory allocation you want to change.
# xm domid Debian_os1
0
The above command listed the domain id of the debian etch virtual os. Then I reduced the memory allocation for the debian etch OS to 98 MB as follows :
# xm mem-set 0 98
The above command reduces the memory allocated to the domain id 0 to 98 MB. Thus I succeeded in reducing the memory allocated to the debian etch os to just 98 MB. Which meant atleast 100 MB memory was freed in the process.
After that I again tried creating the CentOS virtual OS
# xm create -c /root/centos-conf name=centos_1
Now the previous low memory error was rectified but centOS started in the paused state and I set about figuring out how to unpause it - which was quite simple as finding the domain id of the centos_1 image and then unpausing it using the universal xm command.
# xm domid centos_1
2
# xm unpause 2
That done, eventually I got the CentOS login screen (See figure below).Of course, if I have enough memory, I can start any number of these virtual OSes following the above methods. Xen uses VNC to display the virtual OS. So if you are starting say 10 virtual OSes, each will have its own VNC window. You can even start Xen on a server say, and then access a complete independent OS using a VNC client from a remote machine.
Uses of Xen Virtualisation
Here are a couple of ways I figured out how Xen could be put to good use.
- If you are a student interested in getting hands on networking skills, then you can set up your own virtual networking lab on your home computer provided you have at least 1 GB RAM. Using three or more virtual OSes, you can set up a virtual network lab and try out skills like routing, bridging , setting up gateways, running firewalls, subnetting your network and more all in the safe confines of a virtual environment.
- If you are a frequent netizen, then you must be aware of the rumor many months back, of a certain very popular public limited company (guess who?) slated to bring out its own OS based on Linux. Well, if such a project were to kick off, then it will most probably be using virtualisation technology like Xen. Using Xen, each user can be given his own copy of a OS complete with root privileges. And since Xen is using VNC to display the desktop, it is most suitable for a network OS. Of course pulling off a massive project of this kind would require humongous amount of memory (to the tune of Terra bytes?). But a well heeled company will have all the resources to successfully start such a project.
- Kernel developers and debugging specialists in the kernel space will find Xen really useful because they could compile code and try out things on the virtual OS that has a good probability of trashing the OS without affecting the parent OS.
- Even application developers on the Linux platform can test their applications on different Linux distributions at the same time by running copies of the distributions simultaneously using Xen on their PC.
- Needs to enable virtualisation in the parent Linux kernel which at this time requires recompiling a kernel from source. But it is bound to change when Intel supports virtualisation at the hardware level on more of its CPUs.
- Needs a good amount of memory for it to be of any use to anybody. I would recommend atleast 1 GB memory even though with a little bit of tweaking like I did above, you might be able to use it with less than 256 MB RAM. Though its practical use will be limited.
- It is a relatively new technology (when compared to commercial products like vmware).
Note to readers: This is an article which I had contributed to Linux Weekly News many months back. You can find the original article here.
No comments:
Post a Comment