
Emulation vs Virtualization vs Containers Explained
Emulation translates a foreign CPU, virtualization runs guest code natively under a hypervisor, and containers share the host kernel. Here is how they differ.
Everything you need to level up your coding skills.

Emulation translates a foreign CPU, virtualization runs guest code natively under a hypervisor, and containers share the host kernel. Here is how they differ.

cgroups v2 replaces v1's many hierarchies with one unified tree and different file names. What changed, how to detect which one you run, and how to migrate.

chroot only changes how a process resolves paths, while pivot_root swaps the mount namespace's root and lets you unmount the old one. Why containers need that.

Read /proc/PID/cgroup to see which cgroup a process is in, then use systemd-cgls and systemd-cgtop to walk the whole tree and find a container's group.

Create a cgroup v2 directory, write memory.max and cpu.max, move a shell into it and watch the kernel cap memory and CPU time. Commands and output included.

Build container isolation by hand: Linux namespaces for what a process sees, cgroups v2 for what it may use, with C code for clone and pivot_root.

Use unshare and nsenter from a shell to create and join Linux namespaces, and watch hostnames, process lists and mounts change inside a new one.

Linux has eight namespace types: mount, PID, network, IPC, UTS, user, cgroup and time. Each one gives a process its own view of one kind of kernel resource.

Learn to write a CPU emulator in C from nothing: registers, memory, the fetch-decode-execute loop, flags, timing, devices, testing and a path to RISC-V.

A practical tour of the Linux KVM ioctl interface: system, VM and vCPU descriptors, memory slots, kvm_run exits, interrupts, CPUID, debugging and threads, in C.

How virtual machines really work, from CPU privilege rings and VM exits to EPT, virtio, containers and confidential VMs, with C code you can read line by line.

Build a working Linux container runtime in C: namespaces, a pivot_root rootfs, cgroup v2 limits, veth networking, seccomp, and what runc adds on top.
We send one email when a new post is published. No spam.