Throughout this tutorial the operating system has been creating illusions: every process believes it has its own CPU (scheduling), its own huge memory (virtual memory) and its own private files (protection). Virtualization takes the same idea one level higher: it makes a whole operating system believe it owns a complete computer, while in reality it shares the hardware with other operating systems.
This is the technology behind cloud computing. When you rent a "server" on AWS, Azure or Google Cloud, you get a virtual machine. When you deploy an app with Docker or Kubernetes, it runs in a container. Even the Linux examples in this tutorial were run inside WSL2, which is itself a lightweight virtual machine on Windows. In this chapter we will see how hypervisors work, why x86 was hard to virtualize, how memory and I/O are virtualized, and how containers achieve isolation with plain Linux kernel features, which we will try out with real commands.
What Is Virtualization?
Virtualization is the technique of creating a software-based (virtual) version of a computing resource, such as a complete machine, so that several isolated environments can share one physical system. The software that creates and manages virtual machines is the hypervisor, also called the Virtual Machine Monitor (VMM).
Some vocabulary:
Host: the physical machine (and, for some hypervisors, the OS running directly on it).
Guest: an operating system running inside a virtual machine.
Virtual machine (VM): the illusion of a complete computer (virtual CPUs, memory, disk, network card) given to one guest.
+-----------+ +-----------+ +-----------+
| App App | | App App | | App App |
|-----------| |-----------| |-----------|
| Guest OS | | Guest OS | | Guest OS |
| (Linux) | | (Windows) | | (Linux) |
+-----------+ +-----------+ +-----------+
| VM 1 | | VM 2 | | VM 3 |
+=================================================+
| Hypervisor (Virtual Machine Monitor) |
+=================================================+
| Hardware: CPUs, RAM, disks, network cards |
+-------------------------------------------------+
Why Virtualize?
Server consolidation: most physical servers were busy only a small fraction of the time. Running ten lightly loaded servers as ten VMs on one machine saves hardware, power and space.
Isolation: a crash or a compromise inside one VM does not affect the others. Each VM has its own kernel.
Running different OSes on one machine: Linux and Windows side by side, or old OS versions for legacy software.
Testing and development: take a snapshot, try something dangerous, roll back.
Cloud computing: providers sell slices of large machines as VMs that can be created in seconds.
Live migration: move a running VM to another physical host for maintenance or load balancing, without stopping it.
Requirements for a Hypervisor (Popek and Goldberg)
In 1974, Popek and Goldberg stated three properties that a true virtual machine monitor must have:
Equivalence (fidelity): a program running in a VM behaves essentially the same as on the real machine (apart from timing and resource availability).
Resource control (safety): the hypervisor is in complete control of the real resources; a guest cannot access anything it was not given.
Efficiency (performance): most guest instructions run directly on the real CPU without the hypervisor stepping in.
Efficiency is the key point. An emulator that interprets every instruction (like the QEMU emulator without acceleration, or an Android emulator running ARM code on an x86 laptop) is correct but slow. A VMM runs guest code natively and only intervenes when necessary.
Trap-and-Emulate
The natural way to do this: run the guest OS kernel in user mode (it thinks it is in kernel mode). Ordinary instructions (add, load, jump) run at full speed. When the guest kernel executes a privileged instruction, such as loading a new page table or disabling interrupts, the CPU traps because it is in user mode. The hypervisor catches the trap, emulates the effect on the guest's virtual CPU state, and resumes the guest.
Guest kernel (really in user mode) Hypervisor (real kernel mode)
add, mov, cmp ... run directly on CPU
cli (disable interrupts) ---trap---> "guest wants interrupts off":
set virtual IF flag = 0 for this VM
next instruction <---resume----
Popek and Goldberg's theorem: trap-and-emulate works if every sensitive instruction (one that reads or changes privileged machine state) is also privileged (traps when run in user mode).
The x86 Problem
Classic x86 broke this rule. About 17 instructions were sensitive but not privileged. The famous example is POPF: in kernel mode it can change the interrupt-enable flag; in user mode it silently ignores that bit instead of trapping. A guest kernel running in user mode that did POPF to re-enable interrupts would be silently ignored and the hypervisor would never know. So pure trap-and-emulate was impossible on x86 before 2005, and three different solutions appeared.
Techniques for CPU Virtualization
1. Binary Translation
Used by early VMware (1999). The hypervisor scans the guest kernel's code just before it runs, and rewrites the problematic sensitive instructions into safe sequences that call the hypervisor. User-mode guest code, which is most code, still runs unchanged. Translated blocks are cached so each piece is translated only once. Clever, but complex.
2. Paravirtualization
Used by Xen (2003). Instead of hiding virtualization from the guest, modify the guest OS so that it knows it is virtualized. The guest kernel replaces sensitive operations with explicit calls to the hypervisor, called hypercalls (the VM equivalent of a system call). Very efficient, but needs a modified guest kernel, which was not possible for closed-source Windows at the time.
Today paravirtualization survives mainly for devices: virtio drivers in Linux guests talk to the hypervisor through shared memory queues instead of pretending to drive real hardware.
3. Hardware-Assisted Virtualization
Intel VT-x (2005) and AMD AMD-V (2006) fixed the problem in hardware by adding a new CPU mode:
Root mode for the hypervisor and non-root mode for guests. Each mode has its own rings 0 to 3, so the guest kernel really runs in ring 0 of non-root mode.
Sensitive operations in non-root mode cause a VM exit into the hypervisor, which handles them and does a VM entry back. Which events cause exits is configured per VM in a control structure (the VMCS on Intel, VMCB on AMD).
This is how modern hypervisors (KVM, Hyper-V, VMware ESXi, Xen HVM, VirtualBox) work. VM exits are expensive (hundreds to thousands of cycles), so much hypervisor engineering goes into avoiding them.
You can see this on Linux in /proc/cpuinfo: the vmx (Intel) or svm (AMD) flag means the CPU supports hardware virtualization, and the hypervisor flag means you are already inside a VM. Inside our WSL2 environment:
$ grep -o -m1 hypervisor /proc/cpuinfo
hypervisor
$ uname -r
6.18.33.2-microsoft-standard-WSL2So the "Linux machine" used in this tutorial is really a guest of Microsoft's Hyper-V hypervisor.
Comparison
Technique | Guest OS modified? | How sensitive instructions are handled | Example |
|---|---|---|---|
Trap-and-emulate | No | They trap to the VMM (only works if all sensitive instructions are privileged) | IBM VM/370 mainframes |
Binary translation | No | VMM rewrites guest kernel code on the fly | Early VMware Workstation |
Paravirtualization | Yes | Guest calls the VMM with hypercalls | Xen PV, virtio drivers |
Hardware-assisted | No | CPU causes a VM exit to the VMM | KVM, Hyper-V, ESXi, VirtualBox |
Type 1 vs Type 2 Hypervisors
Type 1 (bare-metal / native) | Type 2 (hosted) | |
|---|---|---|
Runs on | Directly on the hardware; it is itself a small OS | As an application on top of a normal host OS |
Layers | Hardware → Hypervisor → Guests | Hardware → Host OS → Hypervisor → Guests |
Performance | Better, less overhead | Some extra overhead through the host OS |
Used for | Data centres, cloud servers | Desktops and laptops, testing, learning |
Examples | VMware ESXi, Microsoft Hyper-V, Xen; KVM (the Linux kernel itself becomes the hypervisor) | Oracle VirtualBox, VMware Workstation/Fusion, Parallels Desktop |
The line is blurry in practice. With KVM, Linux loads the kvm module and the kernel itself becomes a hypervisor, while still being a normal OS for other programs; it is usually classed as type 1. With Hyper-V, once it is enabled, even the Windows you log in to runs as a special privileged VM (the "root partition") on top of the hypervisor.
Memory Virtualization
Recall from Paging that the MMU translates virtual addresses to physical addresses using page tables. With VMs there are now three kinds of addresses:
Guest virtual address (GVA)
| guest page tables (managed by guest OS)
v
Guest physical address (GPA) <- what the guest thinks is RAM
| hypervisor's mapping
v
Host physical address (HPA) <- real RAM chips
Shadow Page Tables (software)
The hypervisor builds a shadow page table that maps GVA directly to HPA, and loads that into the real MMU. It marks the guest's own page tables read-only, so every time the guest edits them, a trap lets the hypervisor update the shadow copy. Lookups are fast (one translation), but every guest page-table update costs an expensive trap.
Nested / Extended Page Tables (hardware)
Modern CPUs support two-level translation in hardware: Intel EPT (Extended Page Tables) and AMD NPT (Nested Page Tables, also called RVI). The guest manages its own page tables freely (no traps), and the hypervisor manages a second table for GPA → HPA. The MMU walks both.
Worked example: the cost of a nested page walk. On a TLB miss the hardware must walk the guest's page table. But every guest page-table entry lives at a guest physical address, which must itself be translated through the host's page table.
Guest page table has n = 4 levels, host (EPT) table has m = 4 levels.
For each of the 4 guest levels: translate the address of that guest table through the host table (4 references), then read the guest entry (1 reference). That is 4 × (4 + 1) = 20 references.
The final guest physical address of the data must also be translated through the host table: 4 more references.
Total page-table references = n(m + 1) + m = nm + n + m = (n + 1)(m + 1) - 1
n = 4, m = 4 : (5)(5) - 1 = 24 (native 4-level paging needs only 4)
n = 5, m = 5 : (6)(6) - 1 = 35 (with 5-level paging on both sides)
Up to 24 memory references instead of 4, before the actual data access. This is why the TLB (see Page Tables & TLB) matters even more for VMs, why CPUs cache intermediate translations, and why hypervisors back guests with huge pages (fewer levels to walk). Still, avoiding the traps of shadow paging is usually a bigger win, so nested paging is the default today.
Overcommitting Memory
A host with 64 GB can run VMs whose configured memory adds up to more than 64 GB, betting that they will not all use it at once. Tools for this:
Ballooning: a driver inside the guest (the "balloon") allocates memory on the hypervisor's request. The guest OS, feeling memory pressure, pages out or frees its least useful pages using its own smarter knowledge; the hypervisor reclaims the frames the balloon holds.
Page sharing / deduplication: identical pages (for example, ten VMs running the same OS) are stored once and marked copy-on-write, just like after
fork(). Linux does this with KSM (Kernel Samepage Merging).Hypervisor swapping: as a last resort, the hypervisor swaps guest memory to disk itself, which can cause the thrashing you saw in Thrashing.
I/O Virtualization
Guests also need disks and network cards. Three approaches, in order of speed:
Approach | How it works | Trade-off |
|---|---|---|
Full emulation | Hypervisor imitates a well-known real device (e.g. an Intel e1000 network card). The unmodified guest driver's register accesses trap and are emulated. | Works with any guest; slow (many VM exits) |
Paravirtualized I/O | Guest uses special drivers (virtio-net, virtio-blk) that exchange requests with the hypervisor through shared ring buffers. | Much faster; needs virtio drivers in the guest |
Device passthrough | A physical device (or one slice of it via SR-IOV) is given directly to one VM. The IOMMU (Intel VT-d / AMD-Vi) remaps its DMA so it can only touch that VM's memory. | Near-native speed; the device cannot be shared freely, live migration is harder |
Note how the I/O ideas from I/O Systems (registers, DMA, interrupts, ring buffers) reappear here, now with an extra layer of indirection.
Live Migration
To move a running VM to another host, the common pre-copy method copies all memory pages while the VM keeps running, then re-copies the pages that were modified meanwhile ("dirty" pages), repeating until the remaining set is small. Then the VM is paused for a very short time (often well under a second), the last pages and CPU state are copied, and it resumes on the new host. Its network address moves with it, so clients barely notice.
Containers: OS-Level Virtualization
A VM virtualizes the hardware, so each VM runs its own full kernel. That is strong isolation, but heavy: every VM needs memory for its own kernel, boots like a real computer, and carries a full OS image of gigabytes.
Often we do not need a different kernel. We just want to run an application with its own files, its own process list and its own network, isolated from other applications. A container does exactly that.
A container is a group of ordinary processes running on the host's kernel, which the kernel isolates (gives a private view of the system) and limits (caps resource usage). It is OS-level virtualization: the OS, not the hardware, is virtualized.
Virtual machines Containers
+---------+ +---------+ +---------+ +---------+ +---------+ +---------+
| App A | | App B | | App C | | App A | | App B | | App C |
| Libs | | Libs | | Libs | | Libs | | Libs | | Libs |
| Guest OS| | Guest OS| | Guest OS| +---------+ +---------+ +---------+
+---------+ +---------+ +---------+ | Container runtime (e.g. runc) |
| Hypervisor | +-----------------------------------+
+---------------------------------+ | Host OS kernel (shared) |
| Hardware | +-----------------------------------+
+---------------------------------+ | Hardware |
+-----------------------------------+
There is no "container" object inside the Linux kernel. A container is built from three independent kernel features: namespaces (what a process can see), cgroups (how much it can use), and a layered file system (its own root directory). Security features such as capabilities, seccomp and SELinux/AppArmor (see Protection & Security) are added on top.
1. Namespaces: Isolation of What You See
A namespace wraps a global system resource so that processes inside the namespace see their own isolated instance of it.
Namespace | Isolates | Effect inside the container |
|---|---|---|
PID | Process IDs | Sees only its own processes; its first process is PID 1 |
Mount (mnt) | Mount points | Its own file-system tree, its own |
Network (net) | Interfaces, IP addresses, routing tables, ports | Its own |
UTS | Hostname and domain name | Its own hostname |
IPC | System V IPC, POSIX message queues | Cannot reach other containers' shared memory or queues |
User | User and group IDs | Can be "root" inside while being an ordinary user outside |
Cgroup | View of the cgroup hierarchy | Sees its own cgroup as the root |
Time | Boot-time and monotonic clocks (Linux 5.6+) | Its own clock offsets, useful when migrating containers |
Every process belongs to one namespace of each type, listed under /proc/<pid>/ns. On our system:
$ ls /proc/self/ns
cgroup ipc mnt net pid pid_for_children time time_for_children user utsTry It: A Container in One Command
The unshare command (part of util-linux) starts a program in new namespaces. No Docker, no root: just kernel features. This script was run as an ordinary user on Ubuntu 26.04 (WSL2):
echo "Host: hostname=$(hostname) user=$(whoami) PID of this shell=$$"
echo "Host processes visible: $(ps -e --no-headers | wc -l)"
echo "Host network interfaces:"; ip -br link | awk '{print " " $1, $2}'
unshare --user --map-root-user --uts --pid --net --fork --mount-proc bash -c '
hostname container-1
echo "Inside: hostname=$(hostname) user=$(whoami) PID of this shell=$$"
ps -e -o pid,user,comm
echo "Inside network interfaces:"; ip -br link | awk "{print \" \" \$1, \$2}"
true'
echo "Host again: hostname=$(hostname)"Real output:
Host: hostname=Imran user=imran PID of this shell=1130
Host processes visible: 35
Host network interfaces:
lo UNKNOWN
eth0 UP
Inside: hostname=container-1 user=root PID of this shell=1
PID USER COMMAND
1 root bash
5 root ps
Inside network interfaces:
lo DOWN
Host again: hostname=Imran
(PIDs and process counts will differ on your machine.) Look at what changed:
UTS namespace: we renamed the host to
container-1inside, yet the real hostname was untouched afterwards.PID namespace: the shell inside is PID 1 and
pssees only 2 processes instead of 35. (--mount-procmounts a fresh/procsopsreads the new namespace.) Likeinit, PID 1 in a container is special: it adopts orphans, and if it exits, the whole container ends.Network namespace: there is no
eth0, only a loopback device that is down. A runtime like Docker would now create a virtual Ethernet pair and connect the container to a bridge.User namespace: we are "root" inside. Is that dangerous? Check:
$ unshare --user --map-root-user bash -c 'whoami; cat /proc/self/uid_map; cat /etc/shadow'
root
0 1000 1
cat: /etc/shadow: Permission deniedThe uid_map line means "UID 0 inside = UID 1000 outside, for 1 ID". This root has power only over the namespace's own resources; for real host files the kernel still sees user 1000, so /etc/shadow is denied. This is the protection-domain idea from the previous chapter applied to entire environments.
2. Control Groups (cgroups): Limits on What You Use
Namespaces hide things but do not limit consumption: a container could still use all the CPU and memory. cgroups group processes and apply resource controls to the group as a whole:
cpu: weights (fair share) and hard limits ("at most 1.5 CPUs").
memory: a maximum; if exceeded, the kernel reclaims memory from the group and, if that fails, the OOM killer kills a process inside that group, not a random process on the host.
pids: maximum number of processes, which stops a fork bomb from taking down the host.
io: disk bandwidth and IOPS limits.
Modern distributions use the unified cgroup v2 hierarchy mounted at /sys/fs/cgroup. On our system:
$ stat -fc %T /sys/fs/cgroup
cgroup2fs
$ cat /sys/fs/cgroup/cgroup.controllers
cpuset cpu io memory hugetlb pids rdmaWhen you run docker run --memory=512m --cpus=1.5 --pids-limit=100 ..., Docker simply creates a cgroup and writes those values into files such as memory.max, cpu.max and pids.max.
3. Layered File Systems: Images
A container image (for example python:3.13) is a stack of read-only layers. When a container starts, the runtime puts one thin writable layer on top, using a union file system such as OverlayFS. Reads fall through to the lower layers; the first write to a file copies it up into the writable layer (copy-on-write again). Hundreds of containers can therefore share one copy of the image on disk.
Here is OverlayFS by hand, again inside a user namespace so no root is needed:
mkdir -p ovl/lower ovl/upper ovl/work ovl/merged
echo "from image layer" > ovl/lower/app.conf
echo "base readme" > ovl/lower/README
unshare --user --map-root-user --mount bash -c '
mount -t overlay overlay -o lowerdir=ovl/lower,upperdir=ovl/upper,workdir=ovl/work ovl/merged
echo "changed in container" > ovl/merged/app.conf
echo "new file" > ovl/merged/log.txt
echo "--- merged view (what the container sees)"; ls ovl/merged; cat ovl/merged/app.conf
'
echo "--- lower (image) layer is untouched:"; ls ovl/lower; cat ovl/lower/app.conf
echo "--- upper (container) layer holds only the changes:"; ls ovl/upperReal output:
--- merged view (what the container sees)
README
app.conf
log.txt
changed in container
--- lower (image) layer is untouched:
README
app.conf
from image layer
--- upper (container) layer holds only the changes:
app.conf
log.txt
The container saw one normal directory with all three files. The image layer was never modified; the modified app.conf and the new log.txt exist only in the upper layer. Delete the upper layer and the container is "reset" to the image. That is exactly why changes made inside a Docker container disappear when it is removed, unless you store them in a volume.
Putting It Together: Docker and Kubernetes
Docker (and Podman) give a friendly interface: build images from a
Dockerfile, store them in registries, and run them. Underneath, a low-level runtime such as runc makes the namespaces, cgroups and mounts and thenexecs your program, the samefork/execpattern from Process Creation (fork & exec).The OCI (Open Container Initiative) standardises image format and runtime behaviour, so images built by one tool run with another.
Kubernetes orchestrates containers across many machines: scheduling them onto nodes, restarting failed ones, scaling and load-balancing. It is, in a sense, an operating system for a whole cluster (see Types of Operating Systems on distributed OSes).
Containers are Linux technology at heart. Docker Desktop on Windows and macOS actually runs a small Linux VM and puts the containers inside it, so it combines both technologies.
Virtual Machines vs Containers
Feature | Virtual machine | Container |
|---|---|---|
What is virtualized | Hardware | Operating system (kernel resources) |
Kernel | Each VM has its own kernel | All containers share the host kernel |
Can run a different OS? | Yes (Windows on a Linux host) | No: Linux containers need a Linux kernel |
Startup time | Seconds to minutes (boots an OS) | Typically well under a second (starts a process) |
Size | Gigabytes (full OS image) | Megabytes to hundreds of MB (app plus libraries) |
Memory overhead | A whole guest kernel and OS services per VM | Close to that of a normal process |
Density | Tens of VMs per host | Hundreds or more containers per host |
Isolation | Strong: boundary is the hypervisor and hardware | Weaker: a kernel bug can let a process escape to the host |
Implemented with | Hypervisor + VT-x/AMD-V, EPT/NPT, IOMMU | Namespaces + cgroups + union FS + seccomp/capabilities |
Typical use | Cloud servers, running different OSes, multi-tenant isolation | Microservices, CI pipelines, packaging apps with dependencies |
Why is container isolation weaker? Because every container makes system calls into the same kernel. The Linux kernel offers hundreds of system calls, and a single exploitable bug in any of them can break out of every container on the host. A VM's guest can only talk to the much smaller hypervisor interface. That is why public clouds that run untrusted code from different customers often combine the two:
MicroVMs such as AWS Firecracker (used for AWS Lambda and Fargate) boot a minimal VM in a fraction of a second, giving each customer's container its own kernel.
Kata Containers run each container inside a lightweight VM while keeping the container interface.
gVisor (Google) intercepts the container's system calls with a user-space kernel, so the host kernel is exposed much less.
Common Mistakes
"A container is a lightweight VM." It is a set of isolated processes on the host kernel. There is no guest kernel and no virtual hardware.
"Docker runs Windows containers on Linux." A container uses the host's kernel, so Linux containers need a Linux kernel (on Windows/macOS, Docker Desktop provides one inside a VM).
Mixing up the hypervisor types. Type 1 runs on bare metal (ESXi, Hyper-V, Xen, KVM); type 2 runs as an application on a host OS (VirtualBox, VMware Workstation).
Confusing emulation with virtualization. Emulation interprets or translates every instruction (can run ARM code on x86, slow). Virtualization runs guest code directly on the same kind of CPU and traps only sensitive operations.
Thinking namespaces limit resources. Namespaces control what a process sees; cgroups control how much it can use.
Thinking "root in a container" is always host root. With a user namespace it maps to an unprivileged host UID. (Without one, container root really is UID 0 on the host, limited only by capabilities and seccomp, which is why rootless containers are preferred.)
Saving important data inside a container's writable layer. It disappears when the container is removed; use volumes.
Interview Questions
What is a hypervisor? Differentiate type 1 and type 2.
A hypervisor (VMM) creates and runs virtual machines, giving each one the illusion of its own hardware. Type 1 runs directly on hardware (ESXi, Hyper-V, Xen, KVM) and is used in data centres; type 2 runs as an application on a host OS (VirtualBox, VMware Workstation) and is used on desktops.
What are the Popek and Goldberg requirements?
Equivalence (programs behave as on real hardware), resource control (the VMM fully controls resources) and efficiency (most instructions run directly on the CPU). Trap-and-emulate works if all sensitive instructions are privileged.
Why was x86 hard to virtualize, and how was it solved?
Some sensitive instructions (such as POPF) did not trap in user mode, so trap-and-emulate failed. Solutions: binary translation (VMware), paravirtualization with hypercalls (Xen), and finally hardware support (Intel VT-x, AMD-V) with a root/non-root mode and VM exits.
What is paravirtualization?
The guest OS is modified to know it is virtualized and calls the hypervisor directly with hypercalls instead of executing sensitive instructions. It is efficient but needs guest changes; today it is mostly used for devices (virtio).
Shadow page tables vs nested (extended) page tables?
Shadow tables are software-maintained GVA→HPA tables; lookups are fast but every guest page-table write traps. Nested paging (EPT/NPT) lets the hardware walk guest and host tables itself; no traps, but a TLB miss can cost up to 24 memory references with 4-level tables on both sides.
What is memory ballooning?
A driver inside the guest allocates memory when the hypervisor asks, forcing the guest OS to free or page out its least useful pages; the hypervisor then reclaims the frames held by the balloon and gives them to other VMs.
What is a container? Which Linux features are used to build it?
A group of processes running on the shared host kernel with an isolated view and limited resources. Built from namespaces (PID, mount, network, UTS, IPC, user, cgroup, time), cgroups (CPU, memory, pids, I/O limits), a layered file system such as OverlayFS, plus capabilities, seccomp and LSMs for security.
Namespaces vs cgroups?
Namespaces isolate what a process can see (its own PIDs, hostname, network, mounts). Cgroups limit and account for what it can use (CPU, memory, number of processes, I/O).
VM vs container: which would you choose?
Containers for packaging and deploying many apps quickly and densely on the same OS. VMs when you need a different OS or kernel, or strong isolation between untrusted tenants. In the cloud they are often combined: containers inside VMs, or microVMs like Firecracker.
What is live migration?
Moving a running VM from one physical host to another with minimal downtime, usually by pre-copying memory while it runs, re-sending dirty pages, and pausing briefly only for the final copy.
Summary
Virtualization lets several operating systems share one machine; the hypervisor gives each VM the illusion of its own hardware.
A proper VMM provides equivalence, resource control and efficiency; trap-and-emulate needs every sensitive instruction to be privileged, which classic x86 violated.
Solutions: binary translation, paravirtualization (hypercalls, virtio), and hardware-assisted virtualization (VT-x/AMD-V, VM exits).
Type 1 hypervisors run on bare metal; type 2 run on a host OS.
Memory is virtualized with shadow page tables or hardware EPT/NPT (a nested walk costs up to 24 references for 4+4 levels); overcommit uses ballooning, page sharing and swapping. I/O uses emulation, virtio or passthrough with an IOMMU.
Containers share the host kernel and are built from namespaces (isolation), cgroups (limits) and layered file systems (images). They are light and fast but less isolated than VMs.
This completes the Operating Systems tutorial. You have travelled from a single process to entire virtual machines, and the same few ideas kept returning: abstraction (processes, files, virtual memory, VMs), isolation and protection (dual mode, page tables, domains, namespaces), and sharing resources efficiently (scheduling, caching, copy-on-write). Master those, and every new OS feature you meet will feel familiar.