10

What's the purpose of the /proc/pid/mountinfo file (with pid being numerical process id)?

As far as I can see it reflects contents of the /proc/mounts file but with added information.

Also the file seems to stay the same for all processes: diff for two randomly chosen processes returns no output (diff /proc/3833/mountinfo /proc/2349/mountinfo)

Please note that I'm not asking what does it contain. From the definitions on the internet I see that 'This file contains information about mount points.'. I'm asking why is it present in every process directory? What is its purpose there?

14

Check the kernel documentation for information about files in /proc.

There is one such file per process because not all processes see the same mount points. Chroot is a traditional Unix feature that makes it possible to restrict processes to a subtree of the filesystem tree. A chrooted process would not see mount points outside its root. Linux takes this further with namespaces: a process can compose its own view of the filesystem by grafting subtrees around.

For more information on mount namespaces, see per process private file system mount points and Michael Kerrisk's articles on namespaces on LWN.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.