nsmount is a utility to mount a path from one process' mount namespace to another process' mount namespace.
It works by:
- Opening mount namespace file descriptors for both the source and target PIDs via
/proc/<pid>/ns/mnt - Entering the source namespace using
setns()and cloning the mount atfrom-pathusing theopen_treesyscall - Entering the target namespace using
setns()and attaching the cloned mount atto-pathusing themove_mountsyscall
Requires Linux 5.2+ due to the use of open_tree and move_mount syscalls.
nsmount <from-pid> <from-path> <to-pid> <to-path>