Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

The Short Answer

Virtualization is the technique of running several isolated computers, called virtual machines, on one physical machine. A layer of software, the hypervisor, divides the real processors, memory, storage, and network among the virtual machines, and each one runs its own operating system as if it had the hardware to itself. A VPS or a cloud server is such a virtual machine; see what is a virtual machine.

Why Virtualize

  • Better use of hardware: one powerful server runs many workloads that would each leave a machine mostly idle.
  • Isolation: a crash or a compromise in one VM normally stays in that VM.
  • Speed: a new machine is created from an image in minutes instead of being ordered and installed.
  • Flexibility: VMs can be resized, copied, snapshotted, and moved between hosts.

Hypervisor Types

TypeRuns onExamples
Type 1The hardwareKVM, Xen, ESXi
Type 2A host OSVirtualBox

Type 1 hypervisors run servers; type 2 hypervisors run as an application on a workstation. KVM is usually counted as type 1, because it turns the Linux kernel itself into the hypervisor. The details are in what is a hypervisor.

Hardware Support in the CPU

Modern processors have extensions that let guest code run directly on the CPU while the hypervisor keeps control: Intel VT-x and AMD-V. Check for them on a Linux host:

lscpu | grep -i virtualization
grep -cE 'vmx|svm' /proc/cpuinfo

On a physical host the first command names VT-x or AMD-V, and the second counts the CPU threads that have the flag. Inside a VM, lscpu usually shows "Hypervisor vendor" and "Virtualization type" lines instead. If the flags are missing on a physical machine, virtualization may be switched off in the firmware settings.

Full Virtualization, Paravirtualization, and Containers

  • Full virtualization: the guest runs unchanged and sees emulated hardware. With CPU support, computation runs close to native speed.
  • Paravirtual devices: the guest uses drivers that know they are virtual, which cuts the cost of disk and network access. On KVM these are the VirtIO drivers.
  • Containers: virtualization at the operating system level. Processes share the host's kernel and are isolated by it, with no hardware emulated at all; see what is a container.

What Gets Virtualized

ResourceHow
CPUvCPUs on host threads
MemoryHost RAM given to the guest
StorageImage files or volumes
NetworkVirtual cards on a bridge

The relation between a vCPU and a real core is explained in what is a vCPU.

Gains and Costs

Virtualization adds a small overhead, mostly on disk and network input and output, and places several tenants on one machine. When the host's processors are busy, a VM waits for CPU time, which Linux reports as steal time; see CPU steal time. The host is also a shared point of failure: if it fails, all its VMs stop until they are started elsewhere. Against that stand fast provisioning, snapshots, and the ability to move VMs between hosts.

KVM, the Linux Standard

KVM (Kernel-based Virtual Machine) is built into the Linux kernel. QEMU provides the virtual devices, and tools such as libvirt or Proxmox VE manage the VMs. See what is KVM virtualization, how to install KVM on Ubuntu, and how to install Proxmox VE.

Nested Virtualization

Nested virtualization runs a hypervisor inside a VM, for example to test KVM or to build a lab. It must be supported and switched on at the host and passed through to the VM's CPU model. Inside the guest, the vmx or svm flag in /proc/cpuinfo shows whether it is available.

Was this answer helpful?
Loading...