What is a Virtual Machine?

What is a Virtual Machine?

Virtual Machines (VMs) are a method of running an operating system as if it were a regular program, the same as any other, within another operating system. This makes it possible to run more than one operating system at a time on a single computer. Virtual Machines are a different concept to dual booting, where more than one operating system is installed on a machine but only one OS may be run at once. With virtual machines multiple operating systems can be run simultaneously and data may be shared between them.

Virtual Machines work by emulating an entire computer. The virtual computer is entirely software and does not really exist. To configure a virtual machine the user specifies how many CPUs and how much memory the virtual computer should have. They also specify virtual hard disks which are actually stored as files on the physical underlying system. Then the operating system is installed onto the virtual computer using exactly the same process as if it were a real physical computer.

The real physical computer is often called the host and virtual machines running within the host are sometimes called guests. The resources allocated to the virtual computer cannot exceed the resources available on the host machine. For example if the host computer has 64 GB of RAM then the virtual computer cannot have more than this.

Virtual Machines are useful if you mainly use one operating system but occasionally need features from another. For example, if you mainly run Windows but sometimes want to run Linux software then you can run Linux in a window as if it were a program. Or alternatively the reverse is possible, if you mainly run Linux but sometimes want to run Windows software then you can run Windows within a window in Linux. Any standard Windows software can then be used on Linux.

The following image shows Microsoft Windows running in a virtual machine on top of the Linux operating system simultaneously with other Linux software. It is possible to copy/paste and pass files between the Windows and Linux programs.

Windows running on Linux in a Virtual Machine.

Virtual Machines are also useful for testing the configuration of an operating system. For example if you want to test a change to an operating system but are uncertain if it will work, the change can be tried first in a virtual machine. If the change fails then it doesn’t matter. The virtual machine can be simply erased and a new virtual machine created.

Data centres make extensive use of virtual machines. It is often the case that modern servers are significantly more powerful than the applications that they run. Virtual machines can be used to slice up a large and powerful server into many smaller ones. This improves the efficiency, or utilisation, of the machine. For example, a customer may only require one CPU for their application but the data centre may run servers with more than 64 CPUs. To solve this problem a virtual machine can be created that has only one CPU and this is then allocated to the customer. The server still has 63 CPUs spare that can be allocated to other customers.

Virtual Machines are useful for isolation. If two customers share a server they may require different configurations of the operating system. In this case two separate virtual machines can be placed onto a single physical server, each of which has a different operating system with a different configuration. The two virtual machines will not interfere with each other. This is also a useful property for computer security. The virtual machines prevent one customer from modifying software belonging to another customer that is using the same physical server.

Image Credit: Data Centre by Christopher Bowns