views:

2036

answers:

6

Linux: Which process is causing "device busy" when doing umount?

+14  A: 

Look at the lsof command (list open files) -- it can tell you which processes are holding what open. Sometimes it's tricky but often something as simple as sudo lsof | grep (your device name here) could do it for you.

MarkusQ
+4  A: 

Just in case... sometimes happens that you are calling umount from the terminal, and your current directory belongs to the mounted filesystem.

alvatar
that's got me a few times
Rory
+5  A: 

You should use the fuser command

eg. fuser /dev/cdrom will return the pid(s) of the process using /dev/cdrom

(If you are trying to unmount, you can kill theses process using the -k swith (see man fuser))

Ben
+2  A: 

lsof and fuser are indeed two ways to find the process that keeps a certain file open. If you just want umount to succeed, you should investigate its -f and -l options.

Anonymous
+1  A: 

That's exactly why the "fuser -m /mount/point" exists.

BTW, I don't think "fuser" or "lsof" will indicate when a resource is held by kernel module, although I don't usually have that issue..

+1  A: 
lsof +f -- /mountpoint

(as lists the processes using files on the mount mounted at /mountpoint. Particularly useful for finding which process(es) are using a mounted USB stick or CD/DVD.

mas