I was reading up on this and my initial (incorrect) thought was that it was to do with mount namespaces and chroot.
It got me wondering... I know that if no process exists with access to a file system1, Linux will automatically clean it up if it can. Amongst other things this allows implicit cleanup of initramfs file systems after pivot_root and
I also understand that PID namespaces have one parent namespace and others which are children of it, so all processes are visible to PID
1 started by the kernel.
But I'm less certain about whether or not there is a master mount namespace or even master root file system. There is, of course a root file system used by PID
1, but other than that is any filesystem meaningfully the root file system?
I think my concern comes from so many answers on SO, documentation and blogs all using terminology like "processes have their own view of the file system".
My problem is I don't understand in what sense there is any single file tree to refer to as the file tree...
...name spaces are copied, individually modified, implicitly destroyed. And even the root file system that we all think of as the main one isn't even the first because initramfs (usually) runs first with a different tree and then calls chroot.
So is this terminology technically incorrect, or is there somehow a single file tree that is the master / main one.
1Correct me if I'm wrong but
unshare -m mount /foo /barhas no effect because when the mount command line utility exits, no process will exist in the new namespace, so the new mount will be unmounted automatically.
- If PID 1 is the only process and it has three mount points
/barand then it calls
chroot /foothen both the original
/barwill be unmounted. Again no process exists with access to either