Experimentation is part of the human nature. Experimenting with the operating system, though, can cost us time and money. With a virtual machine, we can try shady applications and wreck the virtual OS, with no consequences whatsoever. Oh, and virtual machines also power a significant part of the Internet.
What is a Virtual Machine
A virtual machine is the emulation of a computer system within our physical PC. It functions exactly as a physical PC would. It powers up, boots, shuts down, and reboots. We can hook up peripheral devices, from USB Flash drives to printers and scanners. The virtual machine even has a BIOS or UEFI of its own, and it needs drivers for the emulated GPU and soundcard.
As with any PC, we must install an operating system to use a virtual machine. If it is a Windows version, we need to activate it with a legitimate product key. If there is a problem, the virtual machine can and will crash, and even produce a blue screen in Windows. We can also infect it with malware, by mistake or on purpose.
The use of a virtual machine can unlock exciting opportunities within our computer. From testing alternative operating systems and less than trustworthy apps to extreme multitasking, our imagination is the limit. And the resources of our physical PC, of course.
How are virtual machines used
Even if you've never heard of a virtual machine, you've used at least one, without realizing it. In fact, you are using a virtual machine this moment, just by reading these lines. More on that later.
The most common use of virtual machines is server virtualization.
Have you heard of VPS hosting? VPS stands for "Virtual Private Server", which is a fancier name for a "virtual machine".
It works like this: the web hosting company uses a powerful physical server. It could have eight Intel Xeon processors, fifteen cores each, 12TB of RAM. Or even more of everything.
When we order a VPS package, the company creates a virtual machine for us within this enormous server. Each VPS has an operating system - usually Linux - with a complete web server. And it runs on the CPU cores and RAM we are paying for.
Many of the websites that you visit are on a VPS, including the one you are reading now.
Apart from web servers, virtualization works with other types of server: mail servers, file servers, domain controllers, etc. Virtualization allows for better usage of the hardware resources. Separate servers would have separate mainboards, cooling systems, power supply units, physical enclosures. Having a single large server with virtualization is cost and space efficient.
Of course, this has the drawback of reduced redundancy. If the server's motherboard fails, all the separate virtual machines go down. It's an all-eggs-in-one-basket scenario.
This is great for the corporate world, but none of us has or needs a $50,000 server at home. And we definitely don't need to run two dozen virtual servers all at once. So, what's the use of a virtual machine at home?
Virtualization at home - the greatest testing environment
Let's say we've never tried a Linux distribution, and we want to see what the fuss is all about. One option is to dual-boot Windows and Linux on our PC.
Dual boot is a commitment, though. We need to reboot to change operating systems. And if we don't like Linux, we need to jump through a few hoops to remove it.
With a virtual machine, we can have a full Linux installation within Windows. Changing the operating system is as simple as switching between open windows. If we get bored with it, we just delete the virtual machine, and Linux is gone. Just like that.
It works the other way around too. We can have a full Windows installation running within our Linux distribution. This way, if we need a Windows-only application, we can run it on the virtual machine. Or we can operate the scanner for which there are no Linux drivers.
Even within the same family of operating systems, we can use a virtual machine. Microsoft itself had added the "Windows XP Mode" to the professional Windows 7 versions. It was nothing more than a virtualization platform specialized for XP. It's always useful to have access to previous OS, in case of incompatible hardware and software.
A virtual machine is also great for testing unstable and experimental operating systems. It is the best way to install e.g. Windows 10 Technical Preview, or the alpha of the next Ubuntu Version. This way, we can give it a try, without having to put up with the instability.
Also, it's important to remember that a virtual environment is separate from our primary operating system. If we try a shady program, and it infects the virtual system, the malware will not spread.
Most of the virtual machine applications can also create "snapshots" with the exact condition of the operating system. No matter how much we wreck the virtual OS, we just restore an earlier snapshot. We will have a 100% functional virtual system in no time flat.
The fact is, if you get used to working with virtual machines, it's hard to do without them.
Can we play games on a virtual machine?
Virtual machines aren't any good for gaming. Not with anything more exciting than browser and flash games.
The primary inhibiting factor is that a virtual machine doesn't use the system's GPU. Instead, it creates a virtual GPU to draw on-screen.
You see, a virtual machine shares the system's processor with the primary OS. But it can't do the same with the GPU. There is no way, so far, to split a GPU's horsepower between the physical and virtual PC.
For a virtual machine to use the system's GPU, it needs a "VGA passthrough". A passthrough would give the virtual system complete control over the GPU. But then the primary system can't use the GPU.
There is a way to do a VGA passthrough with some specific virtual machines (such as QEMU or Xen). But we need a Linux host, two GPUs installed, and the knowledge of how to tinker with the Linux Kernel. As you imagine, the procedure it is more than a bit complicated.
Can any PC run a virtual machine?
A virtual machine borrows CPU power and RAM from the physical system. Both the virtual OS and the main OS run together. That means we must have enough CPU and RAM to go around.
Of course, we can choose how many CPU cores and how much RAM the virtual machine will use.
But it all depends on the virtual operating system we plan to install. And the applications we intend to run.
That means that if we have a PC with 2GB of RAM, we theoretically can run a 32-bit Windows 8 virtual machine, which requires 1GB RAM. But not 64-bit Windows. We can't allocate all the system's RAM to the virtual machine.
For a decent virtual experience, we would recommend at least a dual-core CPU and 4GB RAM. With an i7 and 16GB RAM, we can run multiple virtual machines simultaneously.
We also need a CPU and motherboard that support IOMMU (input/output/memory management unit). It is what allows the system to split up the CPU power and RAM between the main and the virtual OS.
For Intel CPUs, we will find IOMMU as VT-d. AMD refers to it as AMD-V.
To be continued: How to create a virtual machine
There are many platforms to create virtual machines. The two best known for home use are VirtualBox and VMware. VirtualBox is available for free, and mostly open source. VMware has the free VMware Player, and some advanced paid solutions.
In following posts, we will see in detail how to create a virtual machine in Windows and Linux, and even how to install Mac OS X on a Windows/Linux virtual machine.