172

I've installed OSXFUSE in my mac and used sshfs to mount a remote directory. Now I would like to unmount it, but can't find the way. My OS is OSX 10.8 Mountain. Can anyone help?

Kyle Swanson
  • 848
  • 1
  • 8
  • 16
waitingkuo
  • 69,398
  • 23
  • 102
  • 115

13 Answers13

195

Try this:

umount -f <absolute pathname to the mount point>

Example:

umount -f /Users/plummie/Documents/stanford 

If that doesn't work, try the same command as root:

sudo umount -f ...
Timur Mingulov
  • 2,132
  • 1
  • 12
  • 8
175

Don't use umount.

Use

fusermount -u PATH
palswim
  • 10,910
  • 6
  • 47
  • 72
36
sudo diskutil unmount force PATH 

Works every time :)
Notice the force tag

MuhsinFatih
  • 1,505
  • 18
  • 27
  • This did it for me, where nothing else did! Thanks! – drkvogel Aug 24 '18 at 11:57
  • Same here. Nuke the entire site from orbit—it's the only way to be sure. – Darragh Enright Mar 04 '19 at 12:41
  • 1
    Indeed it works every time . Key is the force option :-) For instance : I was getting the following error with umount mount_osxfuse: mount point /Users/mount/root is itself on a OSXFUSE volume diskutil – irsis Nov 04 '19 at 00:29
16

At least in 10.11 (El Capitan), the man page for umount indicates:

Due to the complex and interwoven nature of Mac OS X, umount may fail often. It is recommended that diskutil(1) (as in, "diskutil unmount /mnt") be used instead.

This approach (e.g., "diskutil umount path/to/mount/point") allows me to unmount sshfs-mounted content, and does not require sudo. (And I believe that it should work back through at least 10.8.)

Matt Healy
  • 161
  • 1
  • 2
  • 3
    A broken pipe would sometimes leave the volume in a very bad state. In these cases, only ```diskutil unmount force /path/to/mountpoint``` would help for me. – cw' Aug 10 '16 at 08:47
  • 1
    Incidentally, this only works for me if I use `diskutil umount force ...`. Other methods [here](https://github.com/osxfuse/osxfuse/issues/45) as well. – abalter Nov 07 '16 at 11:58
13

use ps aux | grep sshfs to find the PID of sshfs (It will be the number next to the username)

Then kill -9 $PID, if the other solutions don't work

hjfitz
  • 315
  • 2
  • 7
  • Works on OS X 10.11.0, after suspending it and moving to a different network (leaving the mount point with Input/Output errors). umount didn't work, fusermount not installed – RobM Oct 07 '15 at 16:42
  • This worked for me when I ran into a situation where many appps/processes were beachballing/“stuck“-status-in-top/“U”-status-in-ps. Cheers. – Slipp D. Thompson Aug 16 '17 at 07:32
7

The following worked for me:

hdiutil detach <path to sshfs mount>

Example:

hdiutil detach /Users/user1/sshfs

One can also locate the volume created by sshfs in Finder, right-click, and select Eject. Which is, to the best of my knowledge, the GUI version of the above command.

casew
  • 71
  • 1
  • 1
  • This is something that worked for me without a hitch on macOS Sierra. I suspected this would work flawlessly because on Gui I press the eject button this would be the thing that was happening. – prageeth Nov 09 '16 at 19:42
  • Works perfectly on **macOS Sierra**. – spencer.sm Feb 03 '17 at 23:15
  • Works for me on High Sierrra when the other approaches didn't, but had to add the "-force" option: e.g "hdiutil detach /Users/user1/sshfs -force" – Chris Apr 13 '18 at 21:28
3

In my case (Mac OS Mojave), the key is to use the full path $umount -f /Volumnes/fullpath/folder

lxy
  • 71
  • 3
2

If you have a problems with fusermount command you can kill the process :

ps -ax | grep "sshfs"

2

Just as reference let me quote the osxfuse FAQ

4.8. How should I unmount my "FUSE for OS X" file system? I cannot find the fusermount program anywhere.

Just use the standard umount command in OS X. You do not need the Linux-specific fusermount with "FUSE for OS X".

As mentioned above, either diskutil unmount or umount should work

Christian Butzke
  • 1,050
  • 12
  • 8
2

If your problem is that you mounted a network drive with SSHFS, but the ssh connection got cut and you simply cannot remount it because of an error like mount_osxfuse: mount point /Users/your_user/mount_folder is itself on a OSXFUSE volume, the github user theunsa found a solution that works for me. Quoting his answer:


My current workaround is to:

Find the culprit sshfs process:

$ pgrep -lf sshfs

Kill it:

$ kill -9 <pid_of_sshfs_process>

sudo force unmount the "unavailable" directory:

$ sudo umount -f <mounted_dir>

Remount the now "available" directory with sshfs ... and then tomorrow morning go back to step 1.

0

Just for reference I found this worked for me.

diskutil unmount /path/to/directory/

When I used the umount command I got an error that recommended this diskutil command.

vikingben
  • 1,532
  • 2
  • 23
  • 36
0

You can always do this from finder. Simply navigate to the directory above where the mount is and hit the eject icon over the mounted folder, which will have SSHFS in the name (in the finder). A shortcut to open a folder in the finder from the terminal is

open .

which will open up the current directory in a new finder window. Replace "." with your directory of choice.

marvin
  • 502
  • 4
  • 7
0

if you want to kill all mounted sshfs connections you can use this. I tried it with ubuntu.

ps -ef | grep "sshfs" | awk '{print $2}' | xargs kill -9

I added it to bash_aliases

otto
  • 694
  • 10
  • 28