Two *different* mount points having the *same* absolute path (bind-mount problem)
5
votes
1
answer
6263
views
Scenario
--------
- a NFS share is mounted on
/mnt/temp/dir
(and other shares are mounted in subdirectories),
- I umount
everything there but supposedly, it doesn't work well (maybe I start with umount /mnt/temp/dir
instead of umounting "nested" shares like /mnt/temp/dir/subdir*
first),
- I do mount -o bind /data/temp /mnt/temp
,
- I do mount /mnt/temp/dir
,
- I do mount /mnt/temp/dir/subdir1
... and it works well.
Note: /mnt/temp
is initially hosted on the root (/
) filesystem /dev/sda6
, and /data
is another filesystem from /dev/sda8
.
Problem
-------
I cannot delete the /mnt/temp/dir
directory on the root filesystem:
# mount -o bind / /test/root
# rmdir /test/root/mnt/temp/dir
rmdir: failed to remove `dir': Device or resource busy
Some explanation
-----------------
/mnt/temp/dir
is mounted ***twice***, probably once on the root fs, and once on the /data
fs.
Here is cat /proc/mounts
:
nfsserver:/some/share/ /mnt/temp/dir nfs rw,relatime(...) 0 0
nfsserver:/some/share/ /mnt/temp/dir nfs rw,relatime,(...) 0 0
More interesting, here is cat /proc/1/mountinfo
:
29 20 0:18 / /mnt/temp/dir rw,relatime - nfs nfsserver:/some/share/ rw,(...)
33 31 0:18 / /mnt/temp/dir rw,relatime - nfs nfsserver:/some/share/ rw,(...)
See, the two numbers at the beginning are *different*.
Kernel doc says for these two fields:
(1) mount ID: unique identifier of the mount (may be reused after umount)
(2) parent ID: ID of parent (or of self for the top of the mount tree)
They also have different parents 20 and 31 (root fs and /data
fs), see:
20 1 8:6 / / rw,relatime - ext4 /dev/sda6 rw,(...)
31 20 8:8 /temp /mnt/temp rw,relatime - ext4 /dev/sda8 rw,(...)
If I try to umount /mnt/temp/dir
, I get 2 error messages:
umount.nfs: /mnt/temp/dir: device is busy
umount.nfs: /mnt/temp/dir: device is busy
Question
========
**How can I umount
the "bad" one (mount ID 29)?**
Even the umount(2)
system call takes a path for argument, and not a "mount ID".
Asked by Totor
(21020 rep)
Feb 27, 2015, 06:24 PM
Last activity: Apr 13, 2025, 10:04 PM
Last activity: Apr 13, 2025, 10:04 PM