I often experience a problem to umount a directory:

umount /mnt/dir
umount: /mnt/dir: device is busy

There is one final fixable cause of unmount failing, and that’s an NFS server going down. Here you can use umount -f, but you risk data loss if you do so. (The client may have cached writes that haven’t been confirmed by the server yet, and those writes will be discarded. Apps, however, have already been told the write is successful.)

If umount does not work then the next option is to check which process is accessing the mount point.  The way to check is fuser -vm /mnt/dir, which must be run as root. It will tell you which processes are accessing the mount point.  An alternative is lsof /mnt/dir, which will show each open file on the mount. Again best run as root.

You can run either of these as non-root, but then the output will be limited to your processes—ones from other users will just be silently not shown, even though they will prevent unmounting the filesystem.

The “access” field tells you how its being accessed. In this case, the kernel has it in use as a mount (duh, but unmount will be OK with only this). bash has it as the current working directory (will have to cd to a different directory before unmount) and gvim both has the current directory and has a file open (will need to close that gvim).

How to force the issue:

kill -9 the open process(es) and then once all gone the mount point can be umounted.

fuser has a -k option which will send a signal (default: SIGKILL) to each process using the mount. This is a rather forceful way to stop the mount from being busy. (And of course, be careful of what you SIGKILL!)


Leave a Reply

Your email address will not be published. Required fields are marked *