Virtual machines and hypervisors
How one physical computer is divided into several complete, separate ones: what a hypervisor does, its two types, what the sharing costs, and why the cloud is built on it.
In 30 seconds
A virtual machine is a computer made of software. A program called a hypervisor splits one real machine’s processor, memory and disk into shares, and gives each share to a VM that runs its own operating system.
A type 1 hypervisor runs directly on the hardware; a type 2 runs as a program on your normal operating system.
VMs are kept apart, so one crashing does not harm the others. The cost is a full operating system per VM. Cloud providers rent out VMs on shared servers.
Virtual machines and hypervisors, step by step
Round numbers. A real hypervisor keeps some memory and CPU for itself, and providers often hand out more vCPUs than there are cores. KVM, built into Linux, blurs the line between the two types.
- Step 1: One machine, many computers. A computer normally runs one operating system. A hypervisor is software that divides one physical machine into several virtual machines (VMs). Each VM gets a share of the processor and memory and runs its own complete operating system, as if it had a computer to itself.
- Step 2: Virtual hardware. The guest operating system believes it has ordinary parts. Behind each one, the hypervisor substitutes something else: a virtual CPU is a turn on a real core, the guest’s memory is a slice of the host’s, its disk is usually one large file, and its network card leads to a switch made of software.
- Step 3: Type 1: on bare metal. A type 1 hypervisor is the first software on the machine: it runs directly on the hardware, with no ordinary operating system underneath. Almost everything it does is run VMs, so little is wasted. This is the kind found on servers in data centres.
- Step 4: Type 2: on a host OS. A type 2 hypervisor is an ordinary program. You install it on the operating system you already use, next to your browser, and it asks that host OS for processor time, memory and files. It is easy to set up, and the extra layer makes it somewhat slower.
- Step 5: Isolation. Each VM has its own kernel, memory and disk, and the hypervisor lets none of them reach into another. If VM B crashes or is broken into, A and C carry on untouched. The wall is strong, though not perfect: a bug in the hypervisor itself can breach it, which is rare and treated as serious.
- Step 6: The price: overhead. Every VM carries a whole operating system, so each one costs memory and disk space before its app does any work, and each has to boot. Raw computing is nearly as fast as on the real machine, because modern processors have built-in support for virtualization (Intel VT-x, AMD-V).
- Step 7: How the cloud uses it. A cloud provider fills data centres with servers running hypervisors and rents out the VMs, which it calls instances. Asking for one creates a VM in the spare capacity of some server, usually within minutes. Isolation is what makes it acceptable to share that server with strangers.
Try it yourself
Learn this first
Spotted a mistake on this page?