JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Why Virtualize? VMs and the Hypervisor

The whole cloud rests on one audacious trick: convincing an entire operating system that it owns a computer it does not own. This guide builds that trick from the ground up — what a virtual machine really is, the hypervisor that conjures it, and why one physical box pretending to be many changed computing forever.

The OS was already a master illusionist

By now you have watched the kernel do one thing over and over: hand each program a believable lie. A process thinks it owns the CPU, but really the scheduler is slicing one processor among many. A program thinks it owns a vast, private stretch of memory, but really virtual memory is fooling it with a page table while several programs share the same RAM. A file looks like a tidy stream of bytes, but underneath sits a sprawl of disk blocks. Every rung of this ladder has, in truth, been about the same craft: presenting a clean software illusion on top of messier hardware.

Virtualization takes that same idea and aims it one floor higher. Instead of giving a process the illusion of its own memory, we give an entire operating system the illusion of its own whole computer — CPU, memory, disks, network card, the lot. That illusion of a complete machine, built purely in software, is a virtual machine (a VM). Inside it runs a real, unmodified operating system — call it the guest — happily booting and scheduling and paging, never suspecting that the 'hardware' it sees is itself just another program running on a real machine, the host.

Meet the hypervisor: a kernel for kernels

Who maintains this grand illusion? A new layer of software called the hypervisor, also known by the older, more literal name virtual machine monitor (VMM). The cleanest way to picture it: a hypervisor is to whole operating systems what an ordinary kernel is to ordinary processes. A kernel multiplexes one CPU among many processes and keeps them isolated; a hypervisor multiplexes one physical machine among many guest operating systems and keeps them isolated. It is, quite literally, a kernel whose 'processes' are themselves full kernels.

Recall dual-mode operation: the CPU runs in either privileged kernel mode or restricted user mode, and a guarded few privileged instructions (halt the CPU, edit the page table, talk to a device) are allowed only in kernel mode. Virtualization complicates this beautifully. The guest OS believes it is in kernel mode and tries to run those privileged instructions — but it must not be allowed to truly touch the real hardware, or it could clobber the host and the other guests. So the hypervisor sits in the genuinely most-privileged seat, lets the guest think it is privileged, and quietly intercepts every dangerous move. The next guide unfolds exactly how that interception works, under the name trap-and-emulate.

Two places to stand: bare-metal and hosted

Hypervisors come in two flavors, and the difference is simply what they stand on. A type 1 hypervisor — called bare-metal — runs directly on the hardware with nothing underneath it; it is the lowest layer of software on that box, and the guest OSes sit on top. There is no separate host operating system at all; the hypervisor itself plays that role. This is what runs in serious data centers (VMware ESXi, Xen, Microsoft Hyper-V, the KVM core in Linux), because being closest to the metal means the least overhead and the tightest control.

A type 2 hypervisor — called hosted — runs as an ordinary application inside a normal operating system that boots first. When you launch VirtualBox, VMware Workstation, or Parallels on your laptop, your everyday OS (Windows or macOS) is the host, and the hypervisor is just another program it schedules, like a browser. That program then conjures a VM, and a guest OS boots inside it. The price of this convenience is an extra layer: the guest's requests must pass through the hypervisor and then the host OS before reaching hardware, so a type 2 setup is usually a touch slower than bare-metal. The payoff is that you can run a Linux guest on your Mac while your Mac keeps doing everything else.

  TYPE 1  (bare-metal)               TYPE 2  (hosted)
  +---------+ +---------+            +---------+ +---------+
  | guest   | | guest   |            | guest   | | guest   |
  |  OS  A  | |  OS  B  |            |  OS  A  | |  OS  B  |
  +---------+ +---------+            +---------+ +---------+
  |      HYPERVISOR     |            |      HYPERVISOR     |  <- an app
  +--------------------+            +--------------------+
  |      HARDWARE      |            |   HOST OS (Win/mac) |
  +--------------------+            +--------------------+
                                    |      HARDWARE      |
                                    +--------------------+
Type 1 sits on the bare hardware and is itself the lowest software layer; type 2 runs as an app on top of an existing host OS. The extra host-OS layer is exactly why hosted hypervisors trade a little speed for everyday convenience.

Why bother? The case for the illusion

All this machinery sounds expensive, so it is fair to ask the title's question bluntly: why virtualize at all? The oldest reason is consolidation. A physical server left to run one application typically idles at a fraction of its capacity — vast CPU, RAM, and disk sitting unused. Pack ten guest VMs onto one strong machine and you reclaim that waste, slashing the number of boxes, the power bill, and the floor space. This single economic argument is why virtualization quietly took over the data center long before anyone said the word 'cloud.'

But consolidation is only the start, because a VM is software, and software can be copied, paused, and moved in ways real hardware never could. Isolation: a crash, a security breach, or a runaway program inside one guest is sealed off, unable to reach across into its neighbors or the host. Snapshots: you can freeze a VM's entire state to a file and roll back to it in seconds — a gift for testing risky changes. Encapsulation: a whole running server becomes a movable file you can clone or ship. And legacy support: you can keep an ancient OS alive inside a VM long after its hardware is dust.

The most magical payoff deserves its own name: live migration. Because a VM is just state — its memory, its registers, its virtual devices — a hypervisor can copy that state across the network to a second physical machine while the guest keeps running, then switch over so smoothly the guest never notices it changed bodies. This is how a cloud provider drains a server for maintenance without anyone's website blinking. We will return to the mechanism in a later guide; for now, simply marvel that turning hardware into software made a running computer something you can teleport.

A lighter rival: the container

A full VM is powerful but heavy: every guest hauls along its own complete operating system, with its own kernel, its own boot sequence, its own gigabytes. If you only want to run one application in a clean, isolated box, booting a whole second OS to do it feels like renting an entire house to store one bicycle. This discomfort gave rise to a lighter idea: the container, a form of OS-level virtualization that this rung's later guides explore in depth.

Here is the pivotal difference, and it is the single most important thing to take from this guide. A VM runs a whole guest OS on a hypervisor, so each guest brings its own kernel. A container does not bring its own kernel at all — every container on a machine shares the one host kernel, and the host merely fences each container off into its own private view of the system using two kernel features you will meet soon: namespaces (which hide other processes, file trees, and network interfaces) and control groups (which cap how much CPU and memory each one may use). Because there is no second OS to boot, a container starts in milliseconds and weighs megabytes, not gigabytes.

The road ahead, and one honest caveat

You now hold the map for this whole rung. Guide two opens up trap-and-emulate and explains why the x86 architecture was historically hard to virtualize — some privileged instructions used to fail silently instead of trapping, forcing clever tricks like binary translation until the chip makers added hardware help (Intel's VT-x, AMD's equivalent). Guide three virtualizes the three big resources one at a time: the CPU, memory (with shadow and nested page tables that virtualize the page table you already know), and I/O (with the virtio devices a guest can talk to efficiently). Guides four and five then descend into containers — namespaces, control groups, the overlay image — and weigh them squarely against VMs.

Before you climb on, kill one tempting misconception. Virtualization does not make your software faster — quite the opposite. Every illusion costs something: the hypervisor must intercept and handle the guest's privileged moves, so a virtualized workload almost always runs a little slower than the same code on the bare metal would. What virtualization buys you is not speed but flexibility, isolation, and density — many independent machines safely sharing one. That is the same honest bargain you met with virtual memory, which never made a program faster either; it let programs run at all under tight resources. Pay the small overhead, gain a world where computers are software you can summon, clone, and move at will.