Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I mounted a remote file system using sshfs (version 2.8.4)

sshfs -o allow_root joeuser@example.com: ./example

but unmounting it fails

> fusermount -u example
umount: /home/joeuser/example: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

Any ideas as to what might be causing this error and how one might fix it?

share|improve this question

4 Answers 4

up vote 4 down vote accepted

Some program is using a file in the filesystem you're trying to unmount. It could be a file opened for reading or writing, a current directory, or a few more obscure cases. It could even be due to a directory on the filesystem being a mount point.

To investigate, run lsof +f -- example. It will tell what the process(es) are using the filesystem. Make your own judgement as to whether to make them close files, kill them, or defer the unmount operation.

share|improve this answer

I think you want a lazy unmount:

sudo umount -l example
share|improve this answer
    
I think your suggestion is incorrect. According to the manual page lazy umount Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem *as soon as it is not busy* anymore. So it will not resolve the original issue. Agreed with @Gilles, lsof should help here. –  user83293 Sep 24 '13 at 6:50

I often see "device busy" with sshfs when I have a terminal window open to a directory on the sshfs share. Exiting the terminal or changing directories to a local share then running fusermount -u solves my problems.

share|improve this answer

Running Ubuntu, man fusermount tells about a -z option, which is documented as “lazy unmount”. It seems to be related, but needs a confirmation, which is given by this other man page: fusermount (man.he.net), which says “lazy unmount (works even if resource is still busy)”. One must use it with the -u, the -z option alone, will produce an error. I tried the -z option, and can confirm it do the trick, but this precisely too much looks like a trick: what does it do exactly? Make it be unmounted automatically as soon as the directory is not busy any‑more? I don't know, not documented, so unsafe.

So here is another option, more verbose, but safer: tries to unmount until it successes, as many time as needed, in a loop.

echo -n "Unmounting...";
fusermount -u -q "$MOUNT_POINT";
OK="$?";

while [ "$OK" != "0" ]
do
   sleep 1;
   echo -n ".";
   fusermount -u -q "$MOUNT_POINT";
   OK="$?";
done

echo;

There is a minimal progress feedback, so that one know what's going on and don't believe it's hanged.

This option is acceptable from a shell script; for command line interaction, the use of the -z option is more handy, but one must probably be aware the man page does not document it and there may be doubt about what it exactly do.

share|improve this answer

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.