Open files
Processes with open files are the usual culprits. Display them:
lsof +f -- <mountpoint or device>
There is an advantage to using /dev/<device>
rather than /mountpoint
: a mountpoint will disappear after an umount -l
, or it may be hidden by an overlaid mount.
fuser
can also be used, but to my mind lsof
has a more useful output. However fuser
is useful when it comes to killing the processes causing your dramas so you can get on with your life.
List files on <mountpoint>
(see caveat above):
fuser -vmM <mountpoint>
Interactively kill only processes with files open for writing:
fuser -vmMkiw <mountpoint>
After remounting read-only (mount -o remount,ro <mountpoint>
), it is safe(r) to kill all remaining processes:
fuser -vmMk <mountpoint>
Mountpoints
The culprit can be the kernel itself. Another filesystem mounted on the filesystem you are trying to umount
will cause grief. Check with:
mount | grep <mountpoint>/
For loopback mounts, also check the output of:
losetup -la
Anonymous inodes (Linux)
Anonymous inodes can be created by:
- Temporary files (
open
with O_TMPFILE
)
- inotify watches
- [eventfd]
- [eventpoll]
- [timerfd]
These are the most elusive type of pokemon, and appear in lsof
's TYPE
column as a_inode
(which is undocumented in the lsof man page).
They won't appear in lsof +f -- /dev/<device>
, so you'll need to:
lsof | grep a_inode
For killing processes holding anonymous inodes, see: List current inotify watches (pathname, PID).