'umount' after 'mount --rbind'

Tom H tomh0665 at gmail.com
Sun May 18 21:28:08 UTC 2014


On Sun, May 18, 2014 at 12:40 PM, Sabniveesu Shashank <shashank at linux.com>
wrote:
>
> I am setting up a chroot-jail. In the process, I do a:
> sudo mount --rbind /sys sys/
>
> While exiting, if I'm issuing a 'umount', I get errors like 'device or
resource busy' etc.
>
> I tried suggestions at
>
http://www.unixli.com/q/answers-recursive-umount-after-rbind-mount-120827.html
>
http://www.commandlinefu.com/commands/view/8468/umount-rbind-mount-with-submounts
>
http://unix.stackexchange.com/questions/120827/recursive-umount-after-rbind-mount
> but none are unmounting 'sys' successfully.
>
> Please let me know how ypu would handle such umounts (after 'rbind').

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):


# mount -o rbind /sys /mnt

# awk '{print $2}' /proc/mounts | grep /mnt | sort -r
/mnt/kernel/security
/mnt/kernel/debug
/mnt/fs/pstore
/mnt/fs/cgroup/systemd
/mnt/fs/cgroup/perf_event
/mnt/fs/cgroup/net_cls
/mnt/fs/cgroup/freezer
/mnt/fs/cgroup/devices
/mnt/fs/cgroup/cpuset
/mnt/fs/cgroup/cpu,cpuacct
/mnt/fs/cgroup/blkio
/mnt/fs/cgroup
/mnt

# awk '{print $2}' /proc/mounts | grep /mnt | sort -r | xargs umount
umount: /mnt/fs/cgroup/systemd: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /mnt/fs/cgroup: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /mnt: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

# lsof -Fpcn +D /mnt/fs/cgroup/systemd
p1
csystemd
n/mnt/fs/cgroup/systemd
p658
csystemd
n/mnt/fs/cgroup/systemd/user.slice/user-0.slice/user at 0.service

# lsof -Fpcn +D /mnt/fs/cgroup

# lsof -Fpcn +D /mnt/fs

# lsof -Fpcn +D /mnt
p441
csystemd-logind
n/mnt/devices/virtual/tty/tty0/active


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.

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:

mount -t proc proc "${MOUNTPOINT}"/proc -o nodev,noexec,nosuid
mount -t sysfs sysfs "${MOUNTPOINT}"/sys -o nodev,noexec,nosuid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20140518/ccd675d8/attachment.html>


More information about the ubuntu-users mailing list