2

Let me try to explain the background:

In main bash:

We use

mount --bind /tmp/source /tmp/target
mount --make-shared /tmp/target

to create this shared mount point target

And then we use

unshare -m /bin/bash

to start a child bash. So far everything looks normal.

And then in main bash, we umount the target successfully.

umount /tmp/target

According this kernel document: sharedsubtree. The child bash should also see the target has already umount although the child thread is started by CLONE_NEWNS(unshare -m). But the problem apprears now:

In child bash, we cat /proc/self/mountinfo and found target still exists!

78 48 8:3 /tmp/source /tmp/target rw,relatime shared:1 - ext4 /dev/disk/by-uuid/98708f21-a59d-4b80-a85c-27b78c22e316 rw,errors=remount-ro,data=ordered

This is an unmatch behaviour in above document. In main bash, we cat /proc/self/mountinfo and found taregt has already unmount. Now we could not rmdir target folder because child bash is still holding this shared mount point.

rm -rf /tmp/target
rm: cannot remove ‘/tmp/target’: Device or resource busy

We test this on Ubuntu 14.04 and CentOS 6.6. Is this a kernel bug? Or I misunderstand the shared mount of linux.

4
  • Could you explain for which purpose, specifically, is mount --make-shared used? When there are no mounts within subdirectories, mount --bind is enough. Commented Sep 11, 2015 at 14:54
  • @IncnisMrsi we use it in mesos container to isolate different containers. The problem cause a bug in mesos. issues.apache.org/jira/browse/MESOS-3349
    – haosdent
    Commented Sep 11, 2015 at 16:02
  • I can't test this right now, but does it help if you precede the two mount commands with the command mount --make-shared /tmp ? Commented Sep 12, 2015 at 0:02
  • Yes, we mark the parent of it as share mount point now.
    – haosdent
    Commented Sep 12, 2015 at 7:53

1 Answer 1

0

By default, recent versions of he unshare command set the mount propagation to private. Pass --propagation unchanged to leave it alone.

You must log in to answer this question.

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