
Virtualization
cgroups v1 vs v2: What Changed and How to Migrate
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.
5 min read
Tag
4 posts

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.

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 a working Linux container runtime in C: namespaces, a pivot_root rootfs, cgroup v2 limits, veth networking, seccomp, and what runc adds on top.