Skip to content

Read mountinfo first

 3 min Before explaining a mount, read /proc/self/mountinfo—the kernel’s live table shows what mount(8) output hides.
Published

Jul 19, 2011

When a mount is visible where it shouldn’t be, or missing where it should be, read the kernel’s table before reconstructing the commands:

cat /proc/self/mountinfo

In an lxc-users thread, Michael H. Warfield asked how to inspect propagation flags, and Serge Hallyn pointed him to /proc/self/mountinfo. I was discussing propagation policy and bind-mount topology in the same thread. The file let us inspect what the kernel had arranged.

What mountinfo shows that ordinary mount output hides—acutely so in 2011, when mount(8) still printed /etc/mtab, a userspace file that could drift from reality:

The self in the path is half the tool. Every process reads the table of its own mount namespace, so comparing /proc/<pid1>/mountinfo against /proc/<pid2>/mountinfo is comparing namespaces directly. “Unexpected visibility” localizes fast. First test whether the mounts share a peer group and propagation did what shared mounts do. Then test whether the two processes are in the namespaces you thought they were. If neither settles it, compare the mount and parent IDs, the bind root, and any overmounts; namespace identity and propagation are the first branches, not an exhaustive pair.

The gotcha: mount IDs are not stable—they are reused across mount/unmount cycles and mean nothing across reboots—and peer-group numbers are only meaningful relatively, for matching lines against each other. Today findmnt -o TARGET,PROPAGATION renders the same file legibly, but it is the same file; when the pretty view seems wrong, the raw table settles it.

The directional argument that thread was about is its own note: propagation is a direction.