Virtualisation is a bit of a buzz word at the moment. Virtualisation can be used for all sorts of different computing tasks from server consolidation to cross-platform software development, to running that one "must-have" app in that "I – wish – I – didn’t – have – to – use – this – damned – OS" OS. This article is more at the latter end of that scale. It will tell you about some VM options for linux, and will run you through some tips and tricks for getting the more popular VM’s up and running.
In this section, I’ll run through some of the VM options. Some of these I’ve tried with mixed success, and some I haven’t tried at all. However, it’s worth setting out what the options are, and where I’ve tried them, how I found them.
Xen is a paravirtualisation VM. This means that it requires a modified form of a guest OS, but achieves very high performance. I understand that there is now support for unmodified guest OS’s using special Intel and AMD technologies. Xen is now shipped with many linux distros out of the box, so is widely available. I have not tried it, as the requirement for a modified guest OS seemed too hard from my perspective, and I found easier options that worked for my purposes.
Parallels is a proprietary virtual machine application available for mac, windows and linux. It looks quite promising, but it is a pay solution. I had a go at using the trial version, but for some reason, even though the package compiled fine on my ubuntu system, it would not start properly. Checking on the forums, apparently it required an evaluation license key, however, it would crash before it got to the point where I could enter the evaluation key. Again because there were easier options which worked, I lost patience with parallels, and haven’t had a chance to try it properly.
I have tried qemu, and successfully installed it. However, I found a few drawbacks with this emulator. First, network support for connecting to external networks is quite convoluted. There are easier solutions. I needed connection to an external network, and playing around with the network configuration issues when there were easier options was not my cup of tea. Also, there is no gui for managing virtual machines, and everything is run from the command-line. Whilst I don’t have a problem with doing things from the command-line, I don’t see the point of making things hard for oneself when there are easier options available. So again, I haven’t really put qemu to the test.
vmware is a very well known proprietary virtualisation solution that has been around for a long time. There are two free versions of vmware which run on linux. One is vmware player, and the other is vmware server.
vmware player is treated by vmware as a product for evaluation purposes and is free for peronal non-commercial use. Previously, the big drawback of using vmware player was that you could not create virtual machines. However, this limitation has now been removed and you can create 32 and 64 bit VMs. Furthermore, “unity mode” works in player. I think unity mode is the killer feature of vmware. In unity mode, the windows in the virtual machine appear on your desktop as if they are native. There is no need to have the desktop of the virtual machine displayed underneath. You access the applications through a separate menu, which is accessed by pushing your mouse to the top left corner of the window. The windows are managed by your native window manager, so all the effects of kwin or compiz work with the virtual windows. This implementation makes the “seamless mode” of virtualbox look clunky. On virtualbox, you are stuck with having to have the task bar of the virtual desktop on the native desktop. The windows don’t move smoothly and don’t integrate well with the native window manager. What’s more, with the latest version of player, the speed of the machine and resources used feel like they are the equal of virtualbox. Downloading vmware player is a little bit convoluted. You need to register to do so, however, this is a minor issue. Actually installing the vmware application is simple. As root, you simply type:
vmware server is also free and is treated by vmware as a means to evaluate their server products. Because this article is about desktop virtualisation, I won’t cover this in detail. If you’re into running virtualised servers, then check out vmware server.
VirtualBox is a reasonably mature emulator that has been opened up and released under the GPL. In more recent times, it was owned by Sun, and is now owned by Oracle. However, despite it being released under the GPL, it appears to be dual licensed. It is available in a binary version and a GPL version. The only difference between the two versions appears to be the addition of a few features, which are supposedly targeted at enterprise customers. However, some of these features would also seem to be quite useful in a desktop environment, including USB support and accessing drives on the host. Do not despair if you need these features, because the binary version is available free of charge for personal use and evaluation.
The binary version of VirtualBox was very easy to install on both my Ubuntu and openSuse machines – they have packages available for most of the main distros. The GPL version comes as source, and you will need to compile it. VirtualBox seems to have all the features of vmware player, and is as easy to use, and feels just as fast. However, as set out above, the seamless mode feels clunky when compared with vmware’s unity mode. It’s hard to choose between virtualbox and vmware player, but for me, unity mode is the decider for me.
why use virtualisation on a desktop machine?
When I first heard about virtualisation, I wondered what possible use it would be. However, having used it at work for one purpose, I now use it for all sorts of things. Primarily I use it at work to run the one application I need that is not available on any platform other than Windows. At home, I use virtualisation for a number of tasks. I have a Windows XP virtual machine to test cross-platform development, and also to test web design (particularly css) on IE 6 and 7 and, again, to run an accounting package that my wife needs for her job. I create VM’s for different distros to test applications I develop, and how they work/install on other distros – for example, I develop an application called thinliquidfilm, which had a bug in it for fedora6 users, so I fire a VM with fedora6, fix the bug, test and I’m done. I also have a mail server, which I built on gentoo a while back. Sadly, I can’t remember how it is set up, and I want to add functionality to it. But I don’t want to break it while I’m doing things. So I fire up a VM with a new distro, rebuild the mail server (documenting things this time), and then add the additional functionality for testing. Once done, I can repeat on the actual server, a bit more confident of what I’m doing.
Virtual Tips and Tricks
This is not supposed to be a comprehensive howto on using VirtualBox. VirtualBox has a very good user manual available. This section will just give a quick taste of how to get things up and running using the binary version and creating a virtual machine. I won’t go over installation in any great detail. Just download the package that best suits your distro from the downloads page. Please bear in mind that there are some dependencies you may need, including libxalan-c, libxerces-c and version 5 of libstdc++. These should be available as packages on your distro, so go ahead and install those first. I ran into a bit of an issue when I first installed VirtualBox. Firstly, you’ll need to add your user to the vboxusers group. You can do this using the following command (as root):
usermod -G vboxusers -a [userid]
Replace [userid] with the actual userid. In addition, you need to make sure that VirtualBox can find your cdrom. By default it expects it to be at /dev/cdrom. However, on *buntu (and maybe other distros) cdroms are found at /dev/cdrom0 and /dev/cdrom1 etc. So either create a symlink to /dev/cdrom (as root):
ln -s /dev/cdrom0 /dev/cdrom
or tell VirtualBox where your cdroms are using a system variable:
To make this permanent, insert that line in ~/.bashrc.
update virtualbox after kernel upgrade
Virtualbox uses a number of kernel modules to do its magic. So when you upgrade your kernel, you need to also update the vbox modules, or Virtualbox will not run. Virtualbox provides a nifty way to do this in its init script. So to update the kernel modules, type the following as root:
/etc/init.d/vboxdrv stop /etc/init.d/vboxdrv setup /etc/init.d/vboxdrv start
All going well, you should now be able to start virtualbox
convert from virtualbox to vmware
If you’ve decided you want to give vmware player a try after you’ve been a virtualbox user, rather than reinstalling your virtual machines, you may want to convert your existing virtualbox images to vmware images. This can be done using a couple of tools. First you need to turn your virtualbox image (.vdi) file into a raw disk image. Make sure you’ve got plenty of space on the disk you’re working on, and type:
VBoxManage internalcommands converttoraw existingimage.vdi existingimage.raw
Obviously change existingimage to the name of the virtualbox image you have. That will take a while to run. Then you need to use the application qemu-img. This can be found in the qemu package, and should be available in your distro’s repositories. So to convert from the raw disk image to a vmware image, type:
qemu-img convert -O vmdk existingimage.raw existingimage.vmdk
You will then have a .vdmk image. However, this is not the end of the process. To use this image in vmware player, you need to set up a new virtual machine. As you are doing this, choose the option to install the OS later, and create the image with a blank hard disk, also make sure you choose the “disk as a single file” option. Make sure that you specify the correct OS for the virtualbox image as you are installing. Also note where the new virtual machine is being created. Then once you’ve got your vmware VM, you’ll need to copy the .vmdk file you created above to the directory that holds your new virtual machine, replacing the existing .vmdk file using the exact same name. Your new vmware VM should now work using your old virtualbox image.
launching vmware with options
You can launch vmware player from the command line using a few options to specify which VM to run and in what mode, without having to go through the library frontend. The options are:
vmplayer --help Usage: vmplayer [OPTION...] <Virtual machine config file> Help Options: -?, --help Show help options Application Options: -v, --version Display the program version -X, --fullscreen Start in fullscreen mode -U, --unity Start in Unity mode -k, --no-kiosk-warning Suppress the warning that appears when a Kiosk Mode ACE is started -K, --no-kiosk-mode Force a Kiosk Mode ACE to start outside of Kiosk Mode -q, --queued-connection=milliseconds timeout for a VM to power on
So to start vmware player running Windows XP in unity mode, I type:
vmplayer -U ~/storage/Windows\ XP\ Professional/Windows\ XP\ Professional.vmx
Check out the video below to see vmware player running on my desktop utilising the kwin desktop effects.