Virtualisation

What is Virtualisation?

One definition is “virtualization is a term that refers to the abstraction of computer resources”. That probably doesn’t help you a lot.

Virtualisation is the operation of software in an environment other than that for which it is intended, by using other software to emulate (pretend to be) that environment.

These definitions are pretty broad. They are probably best illustrated with some examples, provided in the next section.

What Kinds Of Virtualisation Are There?

There are several kinds of virtualisation that you may already be familiar with, which will help to illustrate the concept.

Citrix

The most well known Citrix product is their terminal server, now call XenDesktop. Remote access is provided to a server, which may be implemented as a virtual machine: a server that provides a multi-user Windows compatible system. Typically users connect from their PC using a Windows Remote Desktop Connection (RDP), and can then use normal MS-Office applications and other tools developed for Windows, just as they would on their local machine.

Many companies use the Citrix terminal server, and you may have used it. It is not really suitable for home use, mainly due to the price.

Remote Access Tools
Remote Desktop Tools

There are many tools and communication standards (protocols) to remotely access and control another PC.

In Windows there is RDP (Remote Desktop Protocol). In the Linux world there is VNC (with several different tools that implement the standard). There are also many free, open source, and non-free tools that will do the same thing, either using RDP or VNC, or their own proprietary communication protocols. A well known example is PC-Anywhere.

Many of you have probably seen such tools, or used them yourself.

Although these tools are not virtualisation, they are needed to access your VMs, which is why I mention them here,.

X.11

I suppose I should also include X.11 in this list. X.11 is the basis of most Linux & Unix desktop systems. Unlike Windows, X.11 allows you to start an application on one computer, with the window(s) displayed on another (and keyboard and mouse input taken from the other, also, of course). Using RDP only allows you to access a whole remote desktop, rather than a single application.

Once you get used to the convenience of X.11, you will not want to do without it. This ability to have remote windows is an essential piece of enabling technology or added value for many virtualisation solutions.

ssh

ssh is a secure remote access tool, available on Linux and Unix machines. It allows you to open a remote session to a machine (a real computer or a VM): a command-line session with the option to open X.11 application windows displayed on the desktop from which you are connecting. I use ssh extensively.

There are some ssh server products (Open Source) available for Windows, which will allow you to open individual application windows running on a Windows machine and displaying on, for example, a Linux desktop. I have used one of these products, but there were some side-effects on general system reliability, and I cannot therefor recommend this approach.

Full Virtualisation Solutions
KVM

KVM stands for Kernel-based Virtual Machine. It is available for Linux only. It is an enhancement to the Linux Kernel (the core of the operating system), that makes use of hardware support for virtualisation in the processor (CPU) – if your CPU has such support, which most recent ones do.

KVM allows you to install and run “guest” virtual machines (VMs) on your Linux PC host, with almost no overhead (i.e. almost as fast as if they were the native operating system). The VMs can access (and be accessed by, depending on how you configure the networking) the Internet, use hardware resources of the host (disks, printers, USB devices, sound cards, etc.).

For example, my server currently runs 3 VMs:

KVM is very fast, because most of the virtualisation work is handled in hardware and in the host's Linux kernel. KVM-based Windows VMs run faster and more reliably than on a dedicated laptop. I have run as many as 4 VMs on my server at the same time with no noticeable slowdown. if you want raw performance, for Linux or Windows-XP guests (VMs), then KVM is the best option. I have run my Linux web-server VM under VirtualBox and it ran, but noticeably slower.

The great thing about KVM is that, if you have a suitable Linux system, you can easily and painlessly add KVM VMs without risk or disruption, since any errors will be contained in the VM and not interfere with the host.

KVM has some limitations:.

You can install both KVM and VirtualBox on a Linux host, but you cannot run them at the same time (VirtualBox will give you a warning that you should remove the KVM kernel extensions, but you can safely ignore this). This means that you can experiment with both, to find out which suits you best, and then stick with the one you get on better with.

There is a companion product for KVM: virt-manager. This provides a GUI for creating and running your VMs, very similar to VirtualBox.

VirtualBox

VirtualBox is a free Open-Source virtual machine system from Oracle. It runs on a large range of host operating systems (Windows, Linux, Macintosh and OpenSolaris), and supports a wide range of guest (VM) operating systems: Windows (NT 4.0, 2000, XP, Server 2003, Vista, Windows 7/8/8.1/10), DOS/Windows 3.x, Linux, Solaris, OpenSolaris, and OpenBSD.

This is a professional quality product. I use it myself, and it is very easy and problem-free. It is my virtualisation platform on my Linux laptop, allowing me to run Windows 7 as a guest VM, so that I can use MS-Office, MS-Project and MS-Visio. It utilises hardware virtualisation (VT), so that it is relatively fast.

VirtualBox seems to be based on Xen.

One of the nice advantages of VirtualBox is that you can add some hardware devices to the VM (USB devices such as USB discs and mobile phones, web-cams, etc.,) while the VM is running.

One disadvantage is that VirtualBox checks the UUID of the virtual discs when the VM starts. If you make a backup of the virtual disc using qemu-img, the backup will have a different UUID, and it won't start. There is a way to work-around this problem, but it is complex and time-consuming. For this reason, I make backups of my VirtualBox virtual discs using simple file copies.

VirtualBox allows you to encrypt the virtual discs used by your VM, so that they can't be read except by the VM, after entering the password.

Xen

Xen is another Open Source virtual machine system, supporting a wide range of host operating systems and guest operating systems. Here is a comprehensive guide to Xen.

Being Open Source, Xen is free. It is popular because it is mature, and therefore stable and largely bug-free. It is also very flexible, in terms of the range of supported operating systems.

Xen uses a hypervisor, which manages the scheduling of the host & guest operating systems; in effect the Xen hypervisor is actually the host operating system.

Xen based virtual machines run fast, although not quite as fast as KVM, with low overhead. The main constraint is that it is complex to retrofit a Xen solution to an existing system.

VMware

VMware is a commercial company which sells a range of high quality virtualisation products. For home virtualisation, their product is VMware Workstation, which is available for Windows or Linux hosts, and can run Windows, Linux, Solaris x86, Netware, and FreeBSD guests (VMs). It has a very good reputation, although I have never used it myself.

In addition to the virtualisation system itself, there are also a number of useful scripts to create a virtual machine from an existing system, and to migrate the VM from one host to another.

QEMU

QEMU is an Open Source virtualisation system for Linux. KVM is built on top of QEMU. It allows you to create and run VMs either using KVM hardware virtualisation, or with software (container based) virtualisation, although the latter obviously runs more slowly.

Wine

Wine is a software emulation system for running programs written and compiled for Windows on Linux, Mac OS X, FreeBSD and Solaris. All you need to do is install Wine, configure it (the only mandatory part of the configuration is to decide which version of Windows you want Wine to emulate), and then install your Windows applications.

There is a good description of Wine on Wikipedia.

It sounds like it should be much slower and less efficient that running the Windows applications on a real MS-Windows system, but amazingly this is not true. Most applications run faster under Wine than under Windows on the same hardware.

Many applications (DVD-Shrink, RazorLame, FAB DVD Decryptor, etc.) are easy to install, and work straight away, but some are more problematic.

For many of the difficult cases, there is a great helper application (actually an installation wizard) called PlayOnLinux. It has scripts to install Internet Explorer, Safari, MS-Office, and a huge array of games (the games are the reason why it was created).

I have never been successful in installing MS-Office under Wine, but some people have got it working.

Clustering

Many businesses use clusters of computers for reliability. Basically they all run virtual machines, configured so that if one hardware platform or VM fails, then the VM is started automatically on another (or is already running).

Whilst this class of product is most certainly proper virtualisation, they are usually proprietary and expensive, unsuitable for home users, and not the focus of this paper.

Microsoft Windows

Microsoft also has some products in this area.

There are Window XP Mode (part of Windows 7 Professional and later versions) & Windows Virtual PC (part of Windows 7 Ultimate and later versions). They allow you to run multiple Windows environments, such as Windows XP Mode, from your Windows desktop.

There is also Microsoft Virtual Server, a virtualisation solution that facilitates the creation of virtual machines on the Windows XP, Windows Vista and Windows Server 2003 operating systems.

Although you can use a Microsoft product to host virtual machines, the question is “why would you?”. Why buy something, when you can get something at least as good for free? Also, because Windows has such an inefficient system of virtual memory, and because running VMs uses a lot of memory, performance will be better in pretty much every case if you use a Linux or Unix system as your VM host.

Partial Virtualisation Solutions
Containers

Containers, e.g. using Docker, are a kind of light-weight virtualisation. They are widely used to provide a virtual environment for single applications or groups of related applications such games, web-servers, email servers etc.

Containers are very easy to set up, and run fast, but they do not provide the same degree of isolation (ensuring that a malware infection cannot infect the host system, for example) as a full virtualisation solution. If you want to virtualise a specific application, you might want to consider Containers.

The Drawbacks

You are probably thinking that this all sounds too good to be true. There are, of course some drawbacks and limitations.

Hardware Resources

Anything that you do which makes your PC work harder is likely to impact performance. This means that, if your machine is already working fairly hard, you are likely see noticeable slowdown when running a virtual machine, although this is mainly true if the PC is busy with non-interactive tasks such as running a web-server or mail server.

Virtual machines are likely to have reduced responsiveness to mouse movement.

Memory (RAM) is a critical resource for VMs. You need enough for the host operating system, and for each VM that is running. Windows VMs grab all the allocated RAM when they start, even if it is not used, although Linux and Unix VMs usually do not grab the memory until they need it. Nowadays, most operating systems do not work well with less that 500 MB, and 1 GB is recommended; this means that you shouldn't be thinking of running a VM with less than 2 GB (1 GB for the host, and 1 GB for the VM). If you want to be able to run more than one VM at once, then you should have even more RAM, and that means that your host machine (hardware and operating system) needs to be 64 bit so that you can access all that RAM.

Plug-And-Play Hardware

Generally you lose plug-and-play functionality with VMs (but not with VirtualBox). Although there are easy ways to connect peripheral hardware (such a a Bluetooth interface or a USB memory stick) to a VM, you usually have to specify this when you start the VM. This means that, if you forget or decide partway through a session that you need to connect a certain device to your VM, you will need to shut it down and start it again with the device connected.

Security

In general, security measures (such as anti-virus) on your host operating system will not protect your VMs. Some virus checkers are able to scan the contents of the image files containing the VMs, but most won't. Depending on how you set up Internet access for your VMs, the network traffic from the VM may or may not go though the firewall on you host. You therefore need to take exactly the same security measures for each VM as you would if they were running on their own hardware platform.

Why Virtualise?

If you already have dual-boot

Many of you may already have a PC configured with dual-boot. This is how most people start out, when they start to explore options other than MS-Windows.

If you have been using a dual-boot system for a while, you have probably discovered that, sometimes, it is a real nuisance that you have to reboot to access applications or data that is only available on the other system. For example, I have yet to find anything for Linux that compares with MS-Visio for creating technical diagrams. Some of you probably prefer to use Outlook for your email. On the other hand, Linux has some excellent tools for software development, and also for graphics and photo editing.

With virtual machines, you can have the best of all worlds, available all the time, with no rebooting.

Performance

There is also the issue of speed/performance. There are many tools that are available for many operating systems, and you could have them installed on your host and on your VM. If you want maximum performance, then in almost every case, running it on your Linux host will result in faster execution; up to 20 times faster, in my experience.

If you want to use more than one OS at a time

As mentioned above, with VMs you can run several operating systems at once, on the same hardware. If you are a power-user of computers, you are quite likely to want to mix and match the things that are available on different operating systems. If you are constrained by your work, you may not have the choice of migrating away from one operating system to another.

Here are some reasons why you might want to be able to use more than one operating system:

Region-free DVD reading

Under Windows, DVD Region Coding is enforced. DVD Regions are intended to stop customers from bypassing the release schedule of movies & TV shows by getting them from a region where they are released earlier than where you live.

Windows allows you to change the Region setting of your DVD drive up to 4 times; after that it cannot be changed again.

Linux does not enforce the Region Code. You can read and play a DVD from any region. This is really handy if, like me, you sometimes order DVDs from the USA (e.g. TV series which are not available in Germany). In order to use this advantage of Linux, it will need to be the host operating system, not a guest under Windows.

Visio, Outlook & other tools that you can’t do without

Everyone has their list of favourite applications. Sometimes it really is a case of not being able to do what you want in any other tool. Sometimes it is just more difficult to do it in a different application. Sometimes it is just a matter of what you are familiar with. All these reasons are perfectly valid.

Some tools that are possible reasons to use Windows include:

Some possible reasons to keep, or start to use, Linux include:

Testing software

If you develop software, you know that you need to test it. Even if you only develop for Windows, there are a number of versions that you probably need to test on. You probably don’t want to have a dedicated PC for each. You also don’t want to have to reboot every time you want to test on a different environment. Similarly, there are lots of varieties and versions of Linux & Unix.

Virtual machines allow you to run all your test environments on the same hardware, and to run some or all of them (depending mainly on how much RAM you have) at once, swapping between them with a couple of mouse clicks.

If you use a VPN (to avoid lock out from other N/W resources)

Some of you will be familiar with using a VPN to connect to your office from home. Some companies also use VPNs to connect to systems at clients’ sites. For security reasons, many VPN software blocks your access to any resources that are connected via the network, except those that are part of the VPN. This means that you will not be able to print to a print server or LAN printer, access file servers, use other networked tools (e.g. databases, CAD tools, etc.) and possibly even use your email or browse the web, while connected to the VPN.

What I do is use a Windows VM to connect to the office VPN. If I want to access some resource that I cannot reach via the VPN, then I go back to my Linux desktop. VMs give you the best of both worlds.

If you want portability of your OS

Sometimes you just want to relocate a working operating system to another hardware platform. There are, of course, limitations. Companies which sell software tend to expect you to pay again if you do this, and their software contains code to check that you are running on the same hardware as when you installed it. If you have a volume licence version of Windows-XP, it will allow you to relocate it without complaining (but any applications that are not volume licenced will need a new licence key). Later versions of Windows cannot be relocated, and single user licences cannot be relocated. There are no such hardware checks on free software like Linux.

There are tools that will allow you to clone a working operating system, such as CloneZilla, but this is not for anyone except experts. A virtual machine, on the other hand, is all in one file (an image file, containing the whole virtual file system and MBR of the VM), and is therefore easy to backup and relocate to another host. If your host system starts to get overloaded, you can just move one or more VMs to another hardware system.

If you want to keep work and private data & tools separate

Most people have private data (documents, emails, browser bookmarks and stored passwords) stored on their work computers, and vice versa. This is fine until you change your employer, or your company gives you a new computer.

You can use virtual machines to keep your data & tools separate. For example, if you have the necessary user privileges, you can create a VM on your office computer for your private stuff. You can create a VM on your home system for your work stuff. You then have clear separation: it is easy to delete it, or move it elsewhere. You have no downside, as you can use both the work and home systems at once.

If you just want to try out another operating system

You might want to try an operating system, or tools that need that O/S, to decide whether to buy. For example, you can usually run Windows for 30 days before you are required to enter a valid licence key. There was a one year period when you could download the new Windows-7 and try it for free for a year, before you needed to buy. You might think you want to buy a MAC, but want to be sure before you pay the hefty price tag. You might be a Linux user, and want to try a different distribution of Linux.

In all these cases, you can install the operating system that you want to try, as a VM. At some point you will need to buy a licence for any non-free software (Linux is free), and they are in some cases fairly expensive, but it is still cheaper than buying a new PC or MAC.

Some Comments About Security

Some readers may be horrified at the idea of running Windows-XP as a virtual machine, given that it is no longer supported by Microsoft: Microsoft are not issuing any more security updates to XP. This is not as large a problem as you may think, because:

  1. The Microsoft update server for Windows-XP is still online, so you can download and install drivers, as long as you are able to get your VM online.
  2. Not only is there a Windows firewall in XP, but in most virtualisation configurations, the VM will also be behind the host's firewall, and in some cases behind a NAT router on the host, and usually also a NAT router in your Internet router. Please note that these comments are only valid for IPv4, and not IPv6.
  3. Most Windows software works on XP (MS-Office, Open-Office, etc.), and that includes most ant-virus software. That means that you have firewalling (as described in the comment above) and anti-virus protection, so you are well protected from malware. If you want even better protection, you can also scan your VM's virtual hard-disc using a malware scanner on the host: stop the VM, and mount the virtual hard-disc as a disc volume on the host (there are lots of forum-posts explaining how to do this - it is easy and quick - and manually scan it; then unmount it and start the VM again.
  4. With the gradual introduction of IPv6, things will change (have already changed for me). IPv6 addresses are globally unique, and there is no equivalent to NAT routing under IPv6. This means that all your IPv6 addresses, whether computers, VMs, printers, LAN storage and mobile phones on your home network are accessible from the Internet. This means that you should ne sure to set up proper fire-walling on your VMs, and on your PCs and servers, to prevent unwanted access.

Compared to later versions of Windows, XP is very light-weight, meaning that it is small and fast. If you want performance, XP is a good option. Also, being old and no longer supported by Microsoft, you can get an installation disc and licence key very cheaply.

The comments about security above (2 and 3) also apply to using other operating systems as guest VMs: you have protection on the guest and the host protections also apply to the guest.

Some Comments About Performance - RDP versus VNC and X11

I am generally a big fan of open standards and non-Microsoft standards; they tend to give you portability and usually better performance. One area where this is not true is remote desktop protocols. RDP, a Microsoft proprietary standard, has vastly superior performance to X11 and VNC. VNC is the standard/default remote desktop protocol for KVM, and you can use it with any guest version of any operating system, but if you want real performance with a Windows guest, RDP is your best option. This means that:

  1. If you are running a Windows guest, you will need at least the Professional variant (the cheaper versions do not allow remote access), and will need to enable remote access (in the System part of the Control Panel).
  2. You will want your VM to have a fixed IP address on your local (home or office) LAN, so that you can reach it from your RDP client: either a static IP address set in the guest, or assigned automatically from your DHCP server (normally part of your Internet router).
  3. If you are running a non-Windows guest VM, you will usually need to install additional software to allow you to access the desktop using RDP. I do not do this on my Linux VMs, as I normally use X11 to open windows to applications which are running on the VM, directly on the host desktop; this gives excellent performance and is very convenient; I usually only have an ssh session ('ssh -X <username>@<systemname>') open to my Linux VMs, which allows remote windows, rather than opening a remote desktop.
  4. Running your guest VMs behind a NAT router (a software router on your host) will ensure that the VM is not reachable from anyone else on your local LAN. The NAT router in your Internet router/modem will prevent access from the Internet. You can, in addition, configure your firewall(s) to limit from where the VM can be accessed.

Of course, you cam simply use the client provided as part of your virtualisation software, but you may find that you cannot get a full screen display using this, and RDP will give you better performance that even this out-of-the-box option.

How To Virtualise

I have written a guide on how to virtualise, here. It describes how to build and run virtual machines on a Linux host, using KVM, virt-manager, and VirtualBox.