Course: Cloud Computing Technologies
Professor: Fulvio Risso, Politecnico di Torino
Source title: Process isolation: Linux cgroups and namespaces.
Source filename: 06 - Lightweight Virtualization - Cgroups and namespaces.pdf.
Length: 35 PDF pages; printed slides 1 and 3-36.
Documentation date: 3 November 2026. Lecture date: not stated. 06 preserves the source filename identifier.
Source and learning route
Original PDF viewer. References below use PDF page order, with printed slide numbers distinguished explicitly. The source was read in full by the end of the lesson; network and mount diagrams were also inspected. Original PDF/figures are retained locally for reference rather than newly redistributed in the public notes.
The lesson builds on Lecture 05 - Computing Virtualization in Linux: Linux already manages processes and resources, but a separate VM is not required for every form of isolation. Read the mechanism overview, then the cgroup example, process-ID trace, network connection and mount trace. Finish by combining the namespace types into a controlled process environment.
The notes preserve the professor’s examples and the follow-up explanations. Quota-versus-memory behavior, user-ID mapping, host-side veth peer inspection and several source corrections are added study guidance supported by the Linux manuals linked in the concept notes. Commands are explained, not executed; no namespaces, workloads or mounts were created for this documentation.
Connected lecture explanation
1. Two different isolation problems
A server may run unrelated services or untrusted submitted code. It needs both resource boundaries and separation of system state. A service can have its own network view while still exhausting shared memory; conversely, a memory-limited process can still share the same interfaces and filesystem arrangement as other services.
Namespaces select resource views and instances; cgroups account for and control resource consumption. Views are kernel-enforced environments, not simply information withheld from a program. Two web servers can each use port 80 in distinct network namespaces because their binding spaces are separate, while their actual CPU and RAM remain shared. Linux Process Isolation and Container Assembly
2. Control a whole service rather than each worker separately
The source’s single-core example puts one busy process in a group with 1024 CPU shares and two in a group with 512 shares. Under continuous contention and the example’s simplified conditions:
Total weight = 1024 + 512 = 1536
Group A = 1024/1536 = 2/3 of CPU time
Group B = 512/1536 = 1/3 in total
Each of B's two equally busy processes = (1/3)/2 = 1/6The displayed top output is approximately 66%, 16% and 17%. Ten workers inside B would still divide B’s group share; their count does not multiply its weight. If A becomes idle, weights allow B to use spare time.
A quota is different: it caps aggregate CPU time per period even when competitors are idle. Added example: 50 ms of CPU time per 100 ms period means half of one CPU’s time on average; exhaustion throttles execution. A hard memory limit can instead require reclaiming memory and, if that fails, OOM killing within the cgroup. Linux Cgroups - Weights Quotas and Memory Limits
3. Namespace types are independent
The kernel associates operations with the relevant namespace state. The page 12 diagram illustrates separate routing tables and interface lists handled by one kernel. Creating a network namespace does not change mount membership; a separate UTS hostname does not create a separate network stack.
| Mechanism | Main question |
|---|---|
| PID namespace | Which process IDs are visible? |
| Network namespace | Which interfaces, routes and port bindings apply? |
| Mount namespace | Which filesystem is attached at each mount point? |
| User namespace | How are identities mapped and privileges scoped? |
| UTS namespace | What hostname and NIS domain name apply? |
| IPC namespace | Which selected communication resources are accessible? |
| Cgroup namespace | How does cgroup membership/hierarchy appear? |
| Cgroup controllers | How much controlled capacity may the workload consume? |
The source lists seven namespace types; this is its table, not an exhaustive timeless Linux inventory. Its general claims about root namespace visibility and nesting need type-specific qualifications. User UTS IPC and Cgroup Namespaces
4. One child process, different PID views
The page 18 C example calls clone() with CLONE_NEWPID | SIGCHLD. Its parent has PID 10380 and receives child PID 10381. The same child reports getpid() = 1 in the new namespace. Its actual parent is outside that PID namespace, so getppid() returns 0 there.
The parent waits using its own visible child identifier. An authorized host caller terminating PID 10381 terminates that same process; there is no independent copy behind PID 1. Visibility from an ancestor namespace does not automatically grant signal permissions. The page 17 upid structure pairs a number with a namespace to illustrate the representation. PID Namespaces and Process Creation
5. Give a network namespace a connection
The source creates a named namespace and a connected veth pair:
sudo ip netns add ns1
sudo ip link add name veth0 type veth peer name veth1 netns ns1Host network namespace Namespace ns1
veth0 <--------------> veth1One endpoint remains on the host; its peer belongs to ns1. The pair is connected by construction, but the source output shows new interfaces as DOWN. Normal IP communication needs interface state and addressing; external communication needs the intended routing/bridging and any NAT/firewall configuration. This connects to Linux VM Networking - NAT Routed Bridged and Isolated.
ip link reports the current network view. sudo ip netns exec ns1 ip link, or sudo ip -n ns1 link show, queries the other view without an interactive shell. Host output can still report peer metadata such as veth0@if2 ... link-netns ns1; ethtool -S veth0 can report peer_ifindex. Resolving the peer’s name requires interpreting that index in its namespace. This is different from blindly inspecting every namespace or assuming host ip link lists all remote endpoints as local interfaces. Network Namespaces and Veth Pairs
6. Mounting attaches storage to a path
Added introductory example: mount a USB filesystem at /data, and /data/notes.txt reaches the USB’s file. The contents are not copied. A mount namespace provides a separate arrangement of these attachments, initially copied from the existing mount list.
unshare --mount, with no program specified, starts a shell in a new mount namespace. It requests mount separation, not a new network/PID/user namespace. In the source example, a bind mount exposes /usr/bin at /mnt:
Inside new mount namespace: /mnt/bash -> underlying /usr/bin/bash
Create /mnt/testfolder: changes underlying /usr/bin directory
Back in original shell: /usr/bin/testfolder exists
/mnt/testfolder is absent in the exampleThe mount arrangement differs, but file changes reach shared storage. Removing a file through the writable bind mount targets the same underlying file. Mount-propagation settings must also be appropriate for private mount changes. Mount Namespaces and Bind Mounts
7. Other namespace examples finish the separation
On pages 30-31, CLONE_NEWUTS lets the child change its hostname from VM to CustomVM while the parent keeps VM. The child also sets CustomDomain as its NIS domain name. uname() returns additional fields, but UTS does not supply a different kernel version.
The user namespace can map inner UID 0 to an ordinary outer identity; namespace root is not automatically host root. IPC namespaces separate selected System V and POSIX IPC resources rather than every communication path. Page 33 changes a displayed cgroup path from /batchjobs/container_id1 to /: the view is relative, and ancestor resource constraints remain. User UTS IPC and Cgroup Namespaces
8. From mechanisms to containers
clone() can create a child with selected namespaces, unshare() creates new separation for selected environment components, and setns() joins an existing namespace where permitted. PID membership has special child-creation semantics rather than renumbering an existing caller.
A container runtime assembles namespaces, mounts, networking, cgroup policies and security restrictions, then launches applications. The application still calls the shared host kernel. A VM instead supplies virtual hardware for a separate guest kernel. The final page introduces Linux containers and Docker as the next step in simplifying setup; it does not teach a complete Docker workflow. Linux Process Isolation and Container Assembly
Material map
| PDF pages | Printed slides | Content |
|---|---|---|
| 1-5 | 1, 3-6 | Attribution, motivation, resource use versus views |
| 6-8 | 7-9 | Cgroups and single-core CPU-share example |
| 9-14 | 10-15 | Namespace overview, independent instances, kernel state, types and nesting |
| 15-18 | 16-19 | PID hierarchy, identifiers, kernel structure and C example |
| 19-25 | 20-26 | Network namespaces, veth creation, inspection, C example and command reference |
| 26-29 | 27-30 | Mount arrangement, bind-mount example, findmnt, setup workflow |
| 30-31 | 31-32 | UTS C example and output |
| 32 | 33 | User and IPC overview |
| 33 | 34 | Cgroup membership-path view |
| 34-35 | 35-36 | Conclusions and transition to containers/Docker |
Important source qualifications
- Namespace hierarchy: page 11’s root-visibility generalization is not valid identically for every type. PID ancestry and network membership differ; host administration can inspect another namespace with permission without a universal combined interface view.
- Shares versus limits: page 8 uses cgroup v1-style
cpu.shares. Its 2:1 weighted sharing is not a hard quota or a fixed CPU speed. Names chosen for groups do not define their policy. - Mount contents: page 26’s wording about a new filesystem is better understood as a new mount arrangement, not automatically new storage. Its statement that
chrootcreates an empty root is inaccurate:chrootchanges pathname resolution to an existing directory. The linked mount concept gives the primary references. - Isolation completeness: every namespace need not be private in every valid deployment, and combining namespaces does not alone prove security. Cgroup/resource policy and permissions still matter.
- Snapshot details: the seven-type list, nesting-depth comment, kernel C layout and mixed cgroup mount output belong to the source’s context. Do not generalize them into universal version-independent rules.
Revision route with answers
Start with the scenario, explain why, then check the linked concept’s retrieval answers.
- Ten workers replace two workers in group B. Does its total share increase? No; its weight stays fixed relative to competing groups. Linux Cgroups - Weights Quotas and Memory Limits
- A process is host PID 7000 and inner PID 1. Which terminates when host PID 7000 is killed? The same process; these are scoped identifiers. PID Namespaces and Process Creation
- Only
veth0appears locally. How can its peer be checked? Read peer metadata, then target the peer namespace if name/configuration resolution is needed. Network Namespaces and Veth Pairs - A writable bind mount exposes shared storage. Are changes private? No; the mapping is separate, not the backing data. Mount Namespaces and Bind Mounts
- A process reports UID 0 and cgroup
/. Does it own the host? No; mapped identity, scoped permissions and ancestor policies still constrain it. User UTS IPC and Cgroup Namespaces - Do isolated process/mount/network views create a separate kernel? No; container processes still share the host kernel. Linux Process Isolation and Container Assembly