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?
lsof | grep /media/whatever to find out what is using the mount.
umount -l (lazy umount) to prevent new processes from using the drive while you clean up.
fuser -mv /path/to/mountpointmight be a more readable alternative for finding out processes using a mointpoint. — Oct 14, 2010 at 17:59
lsof | grepworks better for me.
fuser -mvseems to just dump 80+ of unrelated processes. I am using mount binded directories. — Aug 26, 2017 at 10:27
umount -lis dangerous.
mount -o binda mode
000empty directory on top instead, and clean up via
lsof +f -- /dev/device. — Sep 03, 2017 at 09:19