Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Sometimes when I want to umount a device, e.g.

sudo umount /dev/loop0

I will get the message

umount: /mnt: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

I usually solve this issue by closing a console window (in my case xfce4-terminal) and then umount.

What does this problem mean? Is there some smarter solution?

thanks

share|improve this question
1  
That happens for example if you are still in a shell in that directory to where the device is mounted. –  klapaucius Sep 1 '11 at 15:15
    
I don't remember if I was there but I tried it and you're right, this happened. –  xralf Sep 2 '11 at 13:31
add comment

2 Answers

up vote 4 down vote accepted

It means that some process has a working directory or an open file handle underneath the mount point. The best thing to do is to end the offending process, change its working directory or close the file handle before unmounting.

There is an alternative on Linux though. Using umount -l calls a "lazy" unmount. The filesystem will still be mounted but you won't be able to see or use it, except for processes that are already using it. When the offending program exits (through whatever means) the system will "finish" unmounting the filesystem.

share|improve this answer
2  
Is there a way to find out which process has the open file handle and should be terminated? –  xralf Sep 1 '11 at 19:04
2  
Using lsof is probably the best way. –  bahamat Sep 1 '11 at 20:48
    
e.g. lsof | grep loop0? –  xralf Sep 2 '11 at 13:28
    
No, grep for the mount point. It should list any files underneath. I don't think it will show things that simply have a working directory under the mount point, so it isn't a perfect method. –  bahamat Sep 2 '11 at 15:44
add comment

Given your "usual solution", it means that the shell you have running in your console window has a directory in a file system on that device as its current working directory.

Linux, and Unixes in general, want very badly to keep a file system mounted if a process has a current working directory in that filesystem.

You could just use cd in the console window to get out of a directory in or under /mnt rather than killing the console window, and the shell running inside it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.