Skip to content

Commit 4945c51

Browse files
committed
wishlist: add nullfs entry
Signed-off-by: Christian Brauner <[email protected]>
1 parent 0b444ab commit 4945c51

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,34 @@ This creates a mount namespace where "wootwoot" has become the rootfs. The
105105
caller can `setns()` into this new mount namespace and assemble additional
106106
mounts 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
110138
Extend `struct mnt_id_req` to accept a file descriptor and introduce

0 commit comments

Comments
 (0)