umount: target is busy

umount: target is busy



I have mounted /dev and immediately tried to unmount:


/dev


$ sudo mount -o rbind /dev m
$ sudo umount m
umount: /tmp/m: target is busy.
$ sudo lsof m
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
Output information may be incomplete.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
kdevtmpfs 55 root cwd DIR 0,6 4420 2 m
kdevtmpfs 55 root rtd DIR 0,6 4420 2 m



I have read that fuser can kill processes accessing the mount point, but I would like to understand what is happening in this simple case. Acording to the lsof output does something use the mountpoint as current working directory (cwd)?


fuser


lsof



I do not want to use lazy unmount.




1 Answer
1



You used rbind to mount a filesystem and submounts. In order to unmount a filesystem, you must unmount its submounts first (and the same for their submounts, recursively). But take care!


rbind


mount --make-rslave m
umount -R m



Without the first command, you risk unmounting all the sub-mounts on the source, due to mount propagation. In this case that means all the sub-mounts of /dev, which would have bad effects on your running system ;-).


/dev



Basically mount propagation is a massive pit-trap waiting for you to fall into it :-). It seems like it would have been better if bind mounts disabled it by default.



kdevtmpfs is the kernel thread that maintains devtmpfs. It does not prevent unmounting devtmpfs. This is because the kernel thread runs on a separate mount (like a bind mount). You can't see that original mount; it is in a separate mount namespace. If you want to try and work out why kdevtmpfs shows up in lsof, I don't know, maybe consider that a separate question.


kdevtmpfs


kdevtmpfs


lsof






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Malaysia to Papua New Guinea by motorcycle?

List of Bhojpuri films

PHP code is not being executed, instead code shows on the page