Virtual Machines

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.
Virtual Machine - What is it and Why Would I Need One 01
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.

Server virtualization

Have you heard of VPS hosting? VPS stands for "Virtual Private Server", which is a fancier name for a "virtual machine".
Virtual Machine - What is it and Why Would I Need One 02
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.
Virtual Machine - What is it and Why Would I Need One 03aa
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.
Virtual Machine - What is it and Why Would I Need One 04
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?

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.
Virtual Machine - What is it and Why Would I Need One 07
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.
Virtual Machine - What is it and Why Would I Need One 08
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.
Virtual Machine - What is it and Why Would I Need One 09
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.
Virtual Machine - What is it and Why Would I Need One 09a