Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965056AbcDLVTg (ORCPT ); Tue, 12 Apr 2016 17:19:36 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33843 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933686AbcDLVTe (ORCPT ); Tue, 12 Apr 2016 17:19:34 -0400 MIME-Version: 1.0 Date: Tue, 12 Apr 2016 22:19:32 +0100 Message-ID: Subject: how to unmount an rbind mount ? From: Jason Vas Dias To: linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1455 Lines: 34 Good day - Please could anyone advise - Once one has mounted an alias mount with the 'rbind' option, so that mounts underneath it are also mounted under the new path, how can one unmount that filesystem safely without un-mounting the original mountpoints ? For example, I do this for chroots : $ for d in /dev /proc /sys; do mount -o rbind $d $chroot/$d; done Now, if I want to unmount the chroot device, I cannot do eg. : $ unmount ${chroot}/dev because this will fail since /dev/pts /dev/mqueue etc are still mounted ; if I do: $ unmount -R ${chroot}/dev or $ unmount ${chroot}/dev/pts then /dev/pts will be unmounted from the root device filesystem - the situation is much more horrid to try and unmount ${chroot}/sys or ${chroot}/run . Personally, I think this is rather buggy behaviour by Linux, since I told the kernel I only want to BIND the path ${chroot}/dev to /dev - and recursively bind names beneath ${chroot}/dev/* to /dev/*, with the 'rbind' option, ie. to make an alias of ${chroot}/dev/* for /dev/* - NOT to actually re-mount the devices there . So I think umount should be clever enough to 'un-bind' sub-mounts of mounts with the 'rbind' option, rather than unmount the devices from the root filesystem, which is what currently happens. It does make chroot filesystems very difficult to unmount safely ! Linux badly needs a better umount, IMHO . Are there any plans to improve umount behavior wrt rbind mounts ?