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.
Watt:~# fuser -vm /mnt/Zia/src
USER PID ACCESS COMMAND
/mnt/Zia/src: root kernel mount /mnt/Zia/src
anthony 24909 ..c.. bash
anthony 25041 F.c.. gvim
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).
Watt:~# lsof /mnt/Zia/src
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 24909 anthony cwd DIR 0,26 12288 3527682 /mnt/Zia/src/perl (zia.vpn.home:/home/anthony/src)
gvim 25041 anthony cwd DIR 0,26 12288 3527682 /mnt/Zia/src/perl (zia.vpn.home:/home/anthony/src)
gvim 25041 anthony 6u REG 0,26 16384 3526219 /mnt/Zia/src/perl/.utf8.c.swp (zia.vpn.home:/home/anthony/src)
In this output, you can see the current directories for both bash and gvim (as type
DIR). You can also see which file gvim has open for write.
How to force the issue:
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
umount has an
-l option to perform a lazy unmount. The mount will be removed from the filesystem namespace (so you won't see it under
/mnt/Zia/src anymore, in the example) but it stays mounted, so programs accessing it can continue to do so. When the last program accessing it exits, the unmount will actually occur.
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.)