@@ -105,6 +105,34 @@ This creates a mount namespace where "wootwoot" has become the rootfs. The
105105caller can ` setns() ` into this new mount namespace and assemble additional
106106mounts without copying and destroying the entire parent mount table.
107107
108+ ### Add immutable rootfs (` nullfs ` )
109+
110+ Currently ` pivot_root() ` doesn't work on the real rootfs because it
111+ cannot be unmounted. Userspace has to do a recursive removal of the
112+ initramfs contents manually before continuing the boot.
113+
114+ Add an immutable rootfs called ` nullfs ` that serves as the parent mount
115+ for anything that is actually useful such as the tmpfs or ramfs for
116+ initramfs unpacking or the rootfs itself. The kernel mounts a
117+ tmpfs/ramfs on top of it, unpacks the initramfs and fires up userspace
118+ which mounts the rootfs and can then simply do:
119+
120+ ``` c
121+ chdir (rootfs);
122+ pivot_root(".", ".");
123+ umount2(".", MNT_DETACH);
124+ ```
125+
126+ This also means that the rootfs mount in unprivileged namespaces doesn't
127+ need to become `MNT_LOCKED` anymore as it's guaranteed that the
128+ immutable rootfs remains permanently empty so there cannot be anything
129+ revealed by unmounting the covering mount.
130+
131+ **Use-Case:** Simplifies the boot process by enabling `pivot_root()` to
132+ work directly on the real rootfs. Removes the need for traditional
133+ `switch_root` workarounds. In the future this also allows us to create
134+ completely empty mount namespaces without risking to leak anything.
135+
108136### Query mount information via file descriptor with `statmount()`
109137
110138Extend `struct mnt_id_req` to accept a file descriptor and introduce
0 commit comments