<div dir="ltr"><div class="gmail_extra"><div class="gmail_extra">On Sun, May 18, 2014 at 12:40 PM, Sabniveesu Shashank <<a href="mailto:shashank@linux.com">shashank@linux.com</a>> wrote:</div><div class="gmail_extra">
> </div><div class="gmail_extra">> I am setting up a chroot-jail. In the process, I do a:</div><div class="gmail_extra">> sudo mount --rbind /sys sys/</div><div class="gmail_extra">>  </div><div class="gmail_extra">
> While exiting, if I'm issuing a 'umount', I get errors like 'device or resource busy' etc.</div><div class="gmail_extra">> </div><div class="gmail_extra">> I tried suggestions at</div><div class="gmail_extra">
> <a href="http://www.unixli.com/q/answers-recursive-umount-after-rbind-mount-120827.html">http://www.unixli.com/q/answers-recursive-umount-after-rbind-mount-120827.html</a></div><div class="gmail_extra">> <a href="http://www.commandlinefu.com/commands/view/8468/umount-rbind-mount-with-submounts">http://www.commandlinefu.com/commands/view/8468/umount-rbind-mount-with-submounts</a></div>
<div class="gmail_extra">> <a href="http://unix.stackexchange.com/questions/120827/recursive-umount-after-rbind-mount">http://unix.stackexchange.com/questions/120827/recursive-umount-after-rbind-mount</a></div><div class="gmail_extra">
> but none are unmounting 'sys' successfully.</div><div class="gmail_extra">> </div><div class="gmail_extra">> Please let me know how ypu would handle such umounts (after 'rbind').</div><div class="gmail_extra">
<br></div><div class="gmail_extra">Did an rbind of "/sys" on Debian VM booted via systemd 208-1 while logged in via pts/0 (I don't have this problem when logged on to tty1):</div><div class="gmail_extra"><br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra"># mount -o rbind /sys /mnt</div><div class="gmail_extra"><br></div><div class="gmail_extra"># awk '{print $2}' /proc/mounts | grep /mnt | sort -r</div>
<div class="gmail_extra">/mnt/kernel/security</div><div class="gmail_extra">/mnt/kernel/debug</div><div class="gmail_extra">/mnt/fs/pstore</div><div class="gmail_extra">/mnt/fs/cgroup/systemd</div><div class="gmail_extra">
/mnt/fs/cgroup/perf_event</div><div class="gmail_extra">/mnt/fs/cgroup/net_cls</div><div class="gmail_extra">/mnt/fs/cgroup/freezer</div><div class="gmail_extra">/mnt/fs/cgroup/devices</div><div class="gmail_extra">/mnt/fs/cgroup/cpuset</div>
<div class="gmail_extra">/mnt/fs/cgroup/cpu,cpuacct</div><div class="gmail_extra">/mnt/fs/cgroup/blkio</div><div class="gmail_extra">/mnt/fs/cgroup</div><div class="gmail_extra">/mnt</div><div class="gmail_extra"><br></div>
<div class="gmail_extra"># awk '{print $2}' /proc/mounts | grep /mnt | sort -r | xargs umount</div><div class="gmail_extra">umount: /mnt/fs/cgroup/systemd: device is busy.</div><div class="gmail_extra">        (In some cases useful info about processes that use</div>
<div class="gmail_extra">         the device is found by lsof(8) or fuser(1))</div><div class="gmail_extra">umount: /mnt/fs/cgroup: device is busy.</div><div class="gmail_extra">        (In some cases useful info about processes that use</div>
<div class="gmail_extra">         the device is found by lsof(8) or fuser(1))</div><div class="gmail_extra">umount: /mnt: device is busy.</div><div class="gmail_extra">        (In some cases useful info about processes that use</div>
<div class="gmail_extra">         the device is found by lsof(8) or fuser(1))</div><div class="gmail_extra"><br></div><div class="gmail_extra"># lsof -Fpcn +D /mnt/fs/cgroup/systemd</div><div class="gmail_extra">p1</div><div class="gmail_extra">
csystemd</div><div class="gmail_extra">n/mnt/fs/cgroup/systemd</div><div class="gmail_extra">p658</div><div class="gmail_extra">csystemd</div><div class="gmail_extra">n/mnt/fs/cgroup/systemd/user.slice/user-0.slice/user@0.service</div>
<div class="gmail_extra"><br></div><div class="gmail_extra"># lsof -Fpcn +D /mnt/fs/cgroup</div><div class="gmail_extra"><br></div><div class="gmail_extra"># lsof -Fpcn +D /mnt/fs</div><div class="gmail_extra"><br></div><div class="gmail_extra">
# lsof -Fpcn +D /mnt</div><div class="gmail_extra">p441</div><div class="gmail_extra">csystemd-logind</div><div class="gmail_extra">n/mnt/devices/virtual/tty/tty0/active</div><div class="gmail_extra"><br></div><div class="gmail_extra">
<br></div><div class="gmail_extra">I get the same with "/dev" (related to having a logind session open) if I'm logged on to tty2 or or via pts/0 but not if I'm logged on to tty1.</div><div class="gmail_extra">
<br></div><div class="gmail_extra">I don't know whether this is a feature or a bug but if I were you I wouldn't bind-mount or rbind-mount "/proc" or "/sys" but I'd mount them directly:</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">mount -t proc proc "${MOUNTPOINT}"/proc -o nodev,noexec,nosuid</div><div class="gmail_extra">mount -t sysfs sysfs "${MOUNTPOINT}"/sys -o nodev,noexec,nosuid</div>
<div><br></div></div></div>