Unix & Linux
process open-files unmounting
Updated Mon, 11 Jul 2022 07:07:06 GMT

How do I find out which processes are preventing unmounting of a device?

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.

Comments (3)

  • +0fuser -mv /path/to/mountpoint might be a more readable alternative for finding out processes using a mointpoint. — Oct 14, 2010 at 17:59  
  • +1 – @RiccardoMurri 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  
  • +3umount -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