Sometimes, I would like to unmount a usb device with umount /run/media/theDrive
, but I get a drive is busy
error.
How do I find out which processes or programs are accessing the device?
Use lsof | grep /media/whatever
to find out what is using the mount.
Also, consider umount -l
(lazy umount) to prevent new processes from using the drive while you clean up.
fuser -mv /path/to/mountpoint
might be a more readable alternative for finding out processes using a mointpoint. — Oct 14, 2010 at 17:59 lsof | grep
works better for me. fuser -mv
seems to just dump 80+ of unrelated processes. I am using mount binded directories. — Aug 26, 2017 at 10:27 umount -l
is dangerous. mount -o bind
a mode 000
empty directory on top instead, and clean up via lsof +f -- /dev/device
. — Sep 03, 2017 at 09:19