I am experimenting with mount namespaces. I have a python script, which creates a bind mount, after that a mount namespace with the unshare system call. I print the PID, and pause the script. I can list the mounts with:

nsenter --mount=/proc/PID/ns/mnt

Let the python process be interrupted before calling umount (or let us say it terminates due to some error). Now /proc/PID disappears. Will the system be in a consistenst state? I mean will umount be called automatically, or will the mounts "cleaned up" some other way?

1 Answer 1


A mount namespace, like any other namespace, is removed once all its member processes exit (unless it is kept alive via a bind mount: see man 7 namespaces, search for “Bind mounting”), and when a mount point is removed, all its mounts are implicitly unmounted, see man 7 mount_namespaces:

A mount ceases to be a member of a peer group when … the mount is implicitly unmounted because a mount namespace is removed (because it has no more member processes).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .