Opening a new mount namespace always felt, in my head, like shutting a door behind me. You type unshare -m, and whatever you mount inside stays inside.

I sat down to measure that belief. The first run confirmed it: the tmpfs I mounted inside did not show up outside. Then I turned off a single unshare default, and the same tmpfs appeared in the parent namespace — and stayed there after the process that created it had died. The thing shutting the door was never the namespace: the kernel doesn't give you the isolation, unshare adds it.

The difference isn't a misread setting. The difference is that a mount tree is not a list; it's a kinship chart. A new namespace doesn't reset that chart. It inherits it.

Where I ran the experiment

Every measurement here ran on my own machine, inside Docker Desktop's linuxkit VM, in a privileged debian:13-slim container. Kernel 6.10.14-linuxkit, aarch64, tooling util-linux 2.41.5. The container was destroyed after each run; nothing touched the host's mount table.

I started with a directory bind-mounted onto itself and made it shared:

mkdir -p /lab mount --bind /lab /lab mount --make-shared /lab findmnt -o TARGET,PROPAGATION /lab 

The output was the first surprise:

TARGET PROPAGATION /lab shared,slave 

I asked for shared and got shared,slave. That's not a bug — the container's root is already somebody else's slave (master:40), and I made a shared mount underneath that tree. The kernel documentation defines this composite state explicitly: a mount can be both shared and slave, receiving events from its master while forwarding events to its own peer group. If you think a directory has a single "type", that's the first crack.

Two unshare runs, two outcomes

Here's the measurement that matters. I ran the same command twice — once as-is, once with a single extra option.

# 1) default unshare -m sh -c 'mount -t tmpfs lab-default /lab/x; findmnt -o TARGET,PROPAGATION /lab/x' # inside the child: /lab/x private # in the parent after the child exits: absent # 2) only difference: --propagation unchanged unshare -m --propagation unchanged sh -c 'mount -t tmpfs lab-unchanged /lab/y; findmnt -o TARGET,PROPAGATION /lab/y' # inside the child: /lab/y shared # in the parent after the child exits: /lab/y shared 

In the second case the parent's /proc/self/mountinfo line sat there untouched:

317 298 0:150 / /lab/y rw,relatime shared:42 - tmpfs lab-unchanged rw 

The process that created the mount was long dead. The mount was alive. The namespace closed; the mark it left did not.

The only variable here is --propagation unchanged. Which means the default behaviour comes not from whatever creates the namespace, but from unshare's own initiative.

A product of three facts

The leak doesn't come from one mistake. It comes from three decisions, each correct in its own place, stacking on top of each other.

First, your server's root is very probably shared. systemd does this itself at boot; one line in its source:

if (detect_container() <= 0 && !skip_setup) if (mount(/* source= */ NULL, "/", /* filesystemtype= */ NULL, MS_REC|MS_SHARED, /* data= */ NULL) < 0) 

The comment gives away the intent: it does this only when invoked directly by the kernel. When a container manager invokes it, it assumes the manager knows what it's doing and stays out of the way.

My own blog server bears this out. Kernel 6.8.0-149-generic, systemd 255. A snapshot of one moment — three readings four seconds apart came out identical, though I know this table changes with every deploy: 466 mounts, 464 of them shared, spread over 406 distinct peer groups, with zero mounts carrying a master: field. Nearly everything is shared; nothing is a slave.

Second, the kernel preserves that relationship when it copies a namespace. The documentation's "Clone Namespace" section lists all four cases: if the parent's mount is shared, the child's is shared too and they propagate to each other; if it's a slave, the child is a slave of the same master; if private, it stays private; if unbindable, it stays unbindable. The copy copies the relationship as well.

Third, unshare steps in. util-linux's own man page states it plainly: since version 2.27, unshare automatically sets propagation to private in a new mount namespace — "to make sure that the new namespace is really unshared". The way to turn that off is in the very next sentence of the same paragraph: --propagation unchanged.

Diagram

What I like about this trio is that none of the three is wrong. systemd is right to make the root shared — that's the design that lets a newly attached disk appear in every namespace. The kernel is right to preserve the relationship, because clone is a copy operation, not a reset. And unshare is right to intervene, because isolation is genuinely what the person typing that command expects. The only wrong thing was my assumption: I didn't know who was providing the isolation.

The word "default" covers two different things

At the end of that same man page paragraph there's a note: private is the kernel default anyway. The sentence is true, but it doesn't answer the question I was asking. The kernel's default is the default for a newly created mount. My concern wasn't a new mount — it was a tree I inherited. That tree's state is set by inheritance, not by a default.

The same word standing at two different doors is more than enough to make someone like me read the man page and walk away thinking "fine, it's private already". I walked away.

Propagation is a direction, not a flag

Measuring all four states one by one turned my mental "type" model into a "direction" model. The slave test taught me the most:

mount --bind /b/src /b/src && mount --make-shared /b/src mount --bind /b/src /b/dst && mount --make-slave /b/dst # src: shared,slave dst: private,slave mount -t tmpfs t1 /b/src/a # mount on the master # src/a: present dst/a: present -> crossed over mount -t tmpfs t2 /b/dst/b # mount on the slave # dst/b: present src/b: NOT A MOUNT -> did not cross 

Events flow downhill, never uphill. Both directories show the same data, share the same superblock, and ls output matches exactly — but mount something under one and the other finds out, while the reverse never happens. You can't see this by looking at the two directories; you have to look at the mount table. Black boxes keep their most interesting differences in the columns nobody prints.

The fourth state, unbindable, makes a mount refuse to be bound:

mount --make-unbindable /c/one # -> private,unbindable mount --bind /c/one /c/two # mount: /c/two: wrong fs type, bad option, bad superblock on /c/one, # missing codepage or helper program, or other error. 

The error message has no intention of being helpful. It says "wrong fs type"; what actually happened is a deliberate refusal. I can picture someone hitting that message in production and spending an hour hunting a superblock.

Where the relationship is readable: mountinfo's optional fields

findmnt gives you the name of the state, but not who you're related to. That information lives in /proc/<pid>/mountinfo, in the optional fields before the - separator. I set up a shared mount and its slave and read those lines — below I've kept only the columns I cared about, and the parent= label is mine, added for readability:

298 parent=388 /p/a shared:41 master:40 300 parent=388 /p/b master:41 

Two lines describe the whole chain. /p/a is both a member of peer group 41 and a slave of group 40 — it receives events from the container's root and forwards them to its own group. /p/b carries only master:41: it receives events from group 41, belongs to no group of its own, and therefore passes nothing along. That's where the chain ends.

The kernel documentation defines a third field as well: propagate_from:X, showing the closest dominant peer group a slave receives events from — and the footnote matters. If X is the mount's immediate master, or if there's no dominant group under the same root, only master:X is printed and propagate_from:X never appears. That field never turned up in my lab, so it isn't something I can claim to have seen; I'm relaying its meaning from the documentation.

The practical use: looking at a mount's state alone isn't enough, you have to follow the numbers. That's what makes my blog server's table interesting — 406 distinct shared: numbers and not a single line carrying master:. A wide, flat landscape: hundreds of separate peer groups with no master-slave relationship among them. Inside the container the table is the opposite: the root, and every mount I made under it, receives events from a master.

The documentation's own arithmetic under-predicts its own warning

Propagation's most dramatic consequence is the replication blow-up described in the kernel documentation's FAQ. The question: what happens if you repeatedly rbind a shared tree into its own subdirectory? The document answers and draws it step by step — 2 vfsmounts after the first rbind, 6 after the second. For the third it doesn't draw the tree, it just gives the number — 24 — and leaves a formula: V[i] = i*V[i-1].

So I set up exactly that recipe, starting from a single vfsmount:

mount --bind /d/root /d/root # 1 vfsmount mkdir -p /d/root/tmp /d/root/usr mount --make-shared /d/root # then at each step: mkdir -p /d/root/tmp/mN && mount --rbind /d/root /d/root/tmp/mN 
rbind step The doc's formula Measured on 6.10
0 (start) 1 1
1 2 2
2 6 6
3 24 42
4 120 1806
5 720 ENOSPC

The first two steps match exactly. The paths diverge at the third — meaning the document's drawings stop precisely where its formula starts being wrong. By the fourth step the gap is 15-fold: the doc predicts 120 mounts, the kernel creates 1806.

To find where the gap comes from, I counted the peer groups at each step as well. They all stay in a single group, and that group's membership is exactly the current mount count: 1, 2, 6, 42. The mechanism falls out of that. You hold a tree of N mounts and rbind it onto a point inside that same tree; because the destination's parent sits in a peer group with N members, the copy propagates to every member. N copies × N mounts = N², plus the N you started with: N × (N+1) in total. Check it yourself: 1×2 = 2, 2×3 = 6, 6×7 = 42, 42×43 = 1806.

That also shows where the doc's formula parts ways: the document uses the step index (i) as the multiplier, while the kernel uses the current mount count. For the first two steps the two happen to agree; at the third they separate. Which tells me this is an arithmetic slip in the document rather than a change in kernel behaviour — the document goes wrong at the very first step where it derives the number from the formula instead of from a drawing.

The growth class differs from the doc's description too. V[i] = i*V[i-1] is factorial growth, which the document calls "an exponential function"; the N × (N+1) that came out of the lab nearly squares the count at every step, a rung above exponential. Step five would have asked for 1806 × 1807 = 3,263,442 mounts.

Which is why step five hits a wall:

mount: /d/root/tmp/m5: move_mount() failed: No space left on device. 

(Don't let move_mount() in that error throw you: modern util-linux performs a bind with open_tree + move_mount rather than the classic mount(2). You typed rbind; this is the call that reaches the kernel.)

The wall has nothing to do with disk. It's the fs.mount-max sysctl, default value 100000. In the kernel source, count_mounts() checks the namespace's mount count against that ceiling and returns -ENOSPC if it's exceeded.

I checked the ceiling directly too: in a clean namespace I bound mounts one at a time, the namespace stopped at 99,999 mounts, and the next bind was refused. There's a gap here I should be honest about: reading count_mounts(), I'd have expected it to reach a full 100,000, and I couldn't fully account for the one-mount difference. The likeliest reason is the detail in the paragraph above — since a bind now produces a detached copy via open_tree first, that copy may already be charged when the counter check runs. But I didn't measure that; I'm guessing.

I also looked at the file's history: it was last updated on 23 September 2026, with a formatting series in August 2025 before that. The file isn't unmaintained; the formula survived those passes.

The prescribed fix works, and works completely

In the same FAQ entry, the document offers unbindable as the cure for this explosion. On my first attempt I got the recipe wrong: I made the wrong mount unbindable, and the explosion merely halved. Rereading the document and marking the right mount — the directory the replicas land in — produced an entirely different result:

mount --bind /d/root/tmp /d/root/tmp mount --make-rshared /d/root mount --make-unbindable /d/root/tmp 
rbind step mount count
0 2
1 3
2 4
3 5
4 6
5 7

Linear. Exactly one mount per step. Going from near-quadratic growth to linear is the work of a single --make-unbindable call. That taught me something about trust: I shouldn't trust the document's arithmetic, but I should trust its advice. The number it predicted didn't hold; the fix it prescribed held perfectly.

The real lesson is that "unbindable" shouldn't be read as a security setting. It's a pruning tool — the place where you cut the tree's ability to copy itself.

What this looks like in production

Put the three pieces side by side and an unpleasant possibility appears: the root is shared, propagation is inherited, and the mount ceiling behaves less like a per-namespace allowance than like a shared budget. A self-replicating tree inside a container whose propagation was left open carries the mounts it creates into the parent namespace too. Even with nobody acting maliciously, four or five rbind calls are enough to exhaust the 100,000 budget — and at that point every service on the host that wants a new mount gets ENOSPC.

What I'd watch for this isn't a metric so much as a number: mounts per namespace. findmnt -N <pid> gives you a process's namespace table and wc -l < /proc/<pid>/mountinfo gives you the count; a threshold telling you what fraction of the ceiling you're at beats having none.

Rollback is simpler but worth remembering: when a namespace dies, a mount that leaked into the parent doesn't go with it. I removed the tmpfs I'd leaked with umount /lab/y in the parent and one command was enough — but somebody has to type that command.

On the service side you have a lever besides unshare: PrivateMounts= and MountFlags= in systemd unit files make the same decision for you, per unit. If you call clone(CLONE_NEWNS) from your own code there is no such lever — turning off propagation is entirely on you.

Questions to ask your own setup

The questions I started asking my own systems after these measurements:

  • How many lines in your findmnt -o TARGET,PROPAGATION output say shared? If your root is shared, every script that opens a namespace is relying on unshare's courtesy.
  • Do you open namespaces with unshare, or with your own code calling clone(CLONE_NEWNS) directly? In the second case nobody applies rprivate for you.
  • When you hand a bind mount to a container, do you write the propagation explicitly? Trusting the default works today; writing the intent works tomorrow too.
  • Is there a tree in your mount table that copies itself? Four rbind calls make 1806 mounts; the fifth asks for 3.2 million and hits the ceiling.
  • Does a composite state like shared,slave surprise you? If it does, your model is a "type" model, and it needs to become a "direction" model.

I found one more trace on my server

My blog server has exactly two mounts that aren't shared, and both are from the same family:

private /run/snapd/ns private /run/snapd/ns/lxd.mnt 

That's no coincidence, and not even a guess. The unshare man page sets the condition for a persistent namespace file: the mount holding it must not have propagation type shared, or the operation fails. Look at snapd's source and you find the place where that rule gets enforced — snap-confine scans the optional fields of the mountinfo line for shared:, notes "propagation is not set to shared, good", and if it is shared, makes the directory MS_PRIVATE. So the two exceptions in my 466-mount table are the fingerprint of a program reading that rule and acting on it.

I'd been looking at that table for months and had never asked about those two lines.

Docker acts on the same reflex. Per its official documentation, the default propagation for bind mounts is rprivate; shared, rshared, slave, rslave and private are each opt-in.

Closing

A mount namespace looked like a door to me. It turns out to be a photocopier: it copies the tree, and it copies the kinships along with it. The thing that shuts the door is a step unshare has been quietly adding since 2.27.

In September I looked at something related but not the same: that it wasn't me who turned accept_redirects off, but Docker. There, a tool had written over a value I had set; reading the sysctl, I was thanking the wrong party. Here nothing is written over — there's no number for me to read at all. The kernel supplies no isolation, and the tool doesn't change a value; it adds a call. In the first case I found the wrong author; here the thing I was looking for didn't even have a column: the relationship sits between two numbers, not in a single field.

The practical upshot: "I opened a namespace" guarantees nothing on its own. You need to know which tool provides the guarantee, since which version, and behind which flag — because that flag turns off as easily as one command-line option.

And sometimes a document's drawings and its arithmetic part ways. The drawings stopped at six; the kernel went to forty-two.

Official Sources