Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On linux, I have a file that I've mounted using the -o loop option. I want to unmount it. However it tells me that device is busy. However by doing lsof | grep pathofimagefile I get no results. And yet I can't unmount!

share|improve this question
add comment

7 Answers

up vote 2 down vote accepted

I believe this is what fuser is for. Specifically, fuser -km /path/to/mount/point

share|improve this answer
-k is too kill all processes using it. –  Kyle Brandt Aug 26 '09 at 17:07
well, if you want to unmount it, that's what you gotta do, right? Hopefully people don't just cut and paste commands they see on the internet (and run them as root, and change a bogus directory path to one that's real...) –  chris Aug 26 '09 at 17:44
add comment

In your question, you wrote grep pathofimagefile. Have you tried with grep pathofmountpoint?

Also verify that no process running on your machine has your mount point (or a subdirectory of it) set as its current working directory.

sudo ls -l /proc/*/cwd | grep pathofmountpoint will give you those process numbers.

share|improve this answer
add comment

Make sure you don't have an open shell thats in the mounted directory. I've never looked to see if that shows in lsof or not. Also when doing your lsof try greping on the mount point not the image file itself.

share|improve this answer
add comment

run pwd ... is your terminal still sitting in the pathofimagefile? If so move out of the pathofimagefile and then re-execute umount.

share|improve this answer
I thought of that, and no, it's not. I've been stuck with that before. But that would show up in lsof –  Rory Aug 26 '09 at 21:09
add comment

What about:

sudo lsof | grep loop
share|improve this answer
Nevermind, this just shows the kernel process –  Kyle Brandt Aug 26 '09 at 17:07
add comment

I had the same problem. The directory was not only mounted with -o loop, but it was being exported to NFS using the exportfs command. fuser and lsof both said the device was not in use. Also, the exportfs -u had no complaints. However, NFS was still showing the device in /proc/fs/nfs/exports. I restarted nfs and got this:

Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS services:                                [FAILED]
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]

Then, I could umount the devices. Unfortunately, it's quite difficult to reproduce. Maybe someone can give more insights.

share|improve this answer
add comment

Your Answer


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.