Unmount the directory which is mounted by sshfs in Mac [closed]
Asked Answered
B

13

197

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?

Berbera answered 27/12, 2012 at 16:27 Comment(1)
This question belongs to SuperUser, although there's already ssh - How to avoid sshfs freezing? - Super User thereSonde
A
190

Don't use umount.

Use

fusermount -u PATH
Amby answered 7/4, 2014 at 19:11 Comment(10)
This answer came from @Gurney in the comment for another answer.Amby
fusermount is not found on OS10.8Tejada
Use umount, as the docs say (pointed to by the answer of @opsmason).Butta
the <umount> option works fine under Mac System Version: OS X 10.10.3 even without sudoLys
Wasn't getting umount to work initially because I thought it was unmount—there's no n!Eel
macOS 10.13.4: None of these options have worked for me. "umount: gave me "Resource busy -- try 'diskutil unmount'", and that cmd gave me: "Unmount failed for <path>". Edit: BUT umount -f <path> did work!Jackinthebox
This answer is blatantly wrong, fusermount does not exist in the macOS version of sshfs (sshfs FAQ).Cachucha
Works on macOS 10.14.2.Ilmenite
umount -f /path/to/folder if receiving Resource busy with umount and failed with diskutil (Catalina 10.15.2).Mediatory
Why? What's wrong with umount. This should not have so many upvotes without a reason!Apparently
S
222

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 ...
Sanjuanitasank answered 21/5, 2013 at 16:25 Comment(10)
Using umount -f left me with broken directory giving error: "bash: cd: directory-name: Transport endpoint is not connected"Gurney
Note for future use: the command above works just fine on Mavericks. Also, an absolute path isn't necessary.Pears
Fine on OS X 10.10.2 and homebrewMckelvey
@Gurney - that link doesn't seem to go to what you think it should.Mainsail
Fine on OSX 10.10.4 using umount -f /Users/me/Documents/there without sudoIey
Works on 10.12.1 Sierra with umount -f ~/relative-pathDisrespectful
Fails on 10.13 with error: Operation not permitted. Have to use sudo even for a folder in my homedir.Homologize
For me, it did not work when I used a relative path (cd ~/Desktop; umount -f rambo). It said the path was not currently mounted. It worked with a user relative path (umount -f ~/Desktop/rambo)Enrique
This was the only command that worked after my /Volumes/mymount mount point went sour, giving the error message "rm: /Volumes/mymount Device not configured" when trying to sudo rm it.Capricecapricious
umount -f <path> worked on OSX 10.15.5Gailey
A
190

Don't use umount.

Use

fusermount -u PATH
Amby answered 7/4, 2014 at 19:11 Comment(10)
This answer came from @Gurney in the comment for another answer.Amby
fusermount is not found on OS10.8Tejada
Use umount, as the docs say (pointed to by the answer of @opsmason).Butta
the <umount> option works fine under Mac System Version: OS X 10.10.3 even without sudoLys
Wasn't getting umount to work initially because I thought it was unmount—there's no n!Eel
macOS 10.13.4: None of these options have worked for me. "umount: gave me "Resource busy -- try 'diskutil unmount'", and that cmd gave me: "Unmount failed for <path>". Edit: BUT umount -f <path> did work!Jackinthebox
This answer is blatantly wrong, fusermount does not exist in the macOS version of sshfs (sshfs FAQ).Cachucha
Works on macOS 10.14.2.Ilmenite
umount -f /path/to/folder if receiving Resource busy with umount and failed with diskutil (Catalina 10.15.2).Mediatory
Why? What's wrong with umount. This should not have so many upvotes without a reason!Apparently
S
50
sudo diskutil unmount force PATH 

Works every time :)
Notice the force flag

Seamanship answered 29/8, 2017 at 15:55 Comment(2)
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 diskutilGrubman
The only thing that actually worked. It's a puzzle to me that sodo umount -f didn't work here... I had zombie volumes from sshfsHollo
H
18

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.)

Haiti answered 9/4, 2016 at 19:53 Comment(2)
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.Banian
Incidentally, this only works for me if I use diskutil umount force .... Other methods here as well.Anyways
U
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

Unstudied answered 26/9, 2015 at 21:47 Comment(2)
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 installedAngulate
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.Sparry
B
8

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.

Broek answered 14/11, 2014 at 19:45 Comment(3)
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.Trimorphism
Works perfectly on macOS Sierra.Umont
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"Swen
N
5

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.

Night answered 11/12, 2019 at 9:10 Comment(0)
S
4

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

Spare answered 23/4, 2019 at 4:14 Comment(1)
Today, homebrew suggests "macFuse" (deciding to stop offering osxfuse) -- using umount in my OS X still works with "macFuse" just fine (MacOS 13.4.1)Amitie
B
3

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

Blumenfeld answered 13/12, 2018 at 22:29 Comment(0)
A
2

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

ps -ax | grep "sshfs"

Abacist answered 27/5, 2014 at 16:20 Comment(1)
Or even: killall sshfsIlonailonka
D
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.

Dozer answered 27/7, 2017 at 21:30 Comment(0)
K
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.

Kobi answered 8/1, 2019 at 21:12 Comment(0)
R
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

Ranjiv answered 24/8, 2020 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.