The VikiD Truth

Knowledge base / Computing

computingFreedom | Build | Picolisp | Picolisp Machine | Pil Sources | Linux | BASH | C-Programmming | Operating Systems | Javascipt | Emacs | vim | Pharo Smalltalk | Computer Security | Python | The Compiler | Identifiers | Literals | storage_linkage |

Operating Systems

Virtualization

Here’s the truth behind virtualization: an operating system is just a program that thinks it owns the hardware. Give it something that looks like hardware, and it will happily run – alongside a dozen others on the same machine. That simple trick underpins the cloud, CI pipelines and most server rooms on Earth.

What it is, in plain words

Virtualization means running a complete computer – CPU, memory, disks, network card – in software, on top of a real one. The software that does this is a hypervisor, and each pretend computer is a virtual machine (VM) with its own guest operating system.

There are two classic kinds of hypervisor:

Modern CPUs make this fast with hardware extensions – Intel VT-x / AMD-V for the CPU, EPT/NPT for memory, and VT-d / AMD-Vi (IOMMU) for handing real devices to guests. Guests use virtio paravirtual drivers to talk to the hypervisor efficiently instead of pretending to be old hardware.

A lighter cousin is containers (Docker, Podman, LXC): no separate kernel, just isolated processes sharing the host kernel. Somewhere in between sit microVMs like Firecracker, which boot a tiny VM in a fraction of a second.

Why it matters

An everyday analogy: a block of flats

A physical server is a plot of land. Without virtualization you build one house per plot. With it you build a block of flats: each tenant has their own front door, kitchen and locks (their own OS), but they share the foundations, the water main and the electricity (CPU, RAM, disks). The building manager – the hypervisor – makes sure nobody uses more than their share or walks into a neighbour’s flat. Containers are more like rooms in a shared house: lighter, cheaper, but you share the kitchen (the kernel).

flowchart TB
  subgraph VMs
    G1[Guest OS + apps] --- G2[Guest OS + apps]
  end
  subgraph Containers
    C1[app] --- C2[app]
  end
  VMs --> H[Hypervisor: KVM / Xen / Hyper-V]
  Containers --> K[Shared host kernel]
  H --> HW[Hardware with VT-x / AMD-V]
  K --> HW

A hands-on example: KVM on your own Linux box

Check your CPU supports it:

grep -cE 'vmx|svm' /proc/cpuinfo   # > 0 means yes
ls -l /dev/kvm                      # the KVM device should exist

Install QEMU and libvirt. On Void Linux:

sudo xbps-install -S qemu libvirt virt-manager
sudo ln -s /etc/sv/libvirtd /var/service/
sudo ln -s /etc/sv/virtlockd /var/service/
sudo ln -s /etc/sv/virtlogd /var/service/
sudo usermod -aG libvirt,kvm $USER

Quick and raw – boot an ISO straight from QEMU:

qemu-img create -f qcow2 disk.qcow2 20G
qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -cpu host \
  -drive file=disk.qcow2,if=virtio \
  -cdrom void-live-x86_64.iso -boot d \
  -nic user,model=virtio-net-pci

Or the managed way, with virt-install (or the virt-manager GUI):

virt-install --name voidtest --memory 4096 --vcpus 2 \
  --disk size=20 --cdrom void-live-x86_64.iso --os-variant generic
virsh list --all
virsh snapshot-create-as voidtest clean "fresh install"

Snapshots are where virtualization pays for itself: try a risky change, and virsh snapshot-revert voidtest clean if it goes wrong.

Common misconceptions

Connections

Last edited · 2 revisions

Tags: #Computing