Umounting a bind-mounted filesystem is usually no different from umounting any other filesystem. However, in your case you used the option --rbind
instead of just --bind
with the /dev
and /sys
filesystems, which means you did a recursive mount. From man mount
:
-R
, --rbind
Remount a subtree and all possible submounts somewhere else (so that its contents are available in both places). See above.
Both /dev
and /sys
are not just single filesystems, but have several other things mounted in them (for example there are several cgroups mounted below /sys
), which the recursive mount replicates under your chroot mountpoint.
root@localhost:~# mount | grep 'chroot/sys'
sysfs on /media/chroot/sys type sysfs (rw,nosuid,nodev,noexec,relatime)
none on /media/chroot/sys/fs/cgroup type tmpfs (rw,relatime,size=4k,mode=755)
cgroup on /media/chroot/sys/fs/cgroup/cpuset type cgroup (rw,relatime,cpuset)
cgroup on /media/chroot/sys/fs/cgroup/cpu type cgroup (rw,relatime,cpu)
cgroup on /media/chroot/sys/fs/cgroup/cpuacct type cgroup (rw,relatime,cpuacct)
cgroup on /media/chroot/sys/fs/cgroup/blkio type cgroup (rw,relatime,blkio)
cgroup on /media/chroot/sys/fs/cgroup/memory type cgroup (rw,relatime,memory)
...
These additional mounts are not automatically removed along with their ancestor and are what's preventing you from simply umounting /media/chroot/dev
and /media/chroot/sys
. You need to umount all of those first before you can remove the /dev
and /sys
bind-mounts.
...
umount /media/chroot/sys/fs/cgroup/cpu
umount /media/chroot/sys/fs/cgroup/cpuset
umount /media/chroot/sys/fs/cgroup
umount /media/chroot/sys
umount /media/chroot/dev/pts
umount /media/chroot/dev