55

I used sshfs without sudo to create a directory like

sshfs user@172.19.76.226:/media/user/harddrive /temp/user/harddrive

but when I want to umount the /temp/user/harddrive directory with

umount /temp/user/harddrive

it prompts:

umount: /temp/user/harddrive: Permission denied

so how to umount this directory?

guntbert
  • 13,485
K.Wanter
  • 968

3 Answers3

82

sshfs uses FUSE (File system in USErspace) instead of the regular mount with elevated permissions.

That also means at least on old releases up to 16.04 you can not use umount (the counterpart of mount) to unmount the file system, although this should work as well on 18.04 and newer releases.

Generally you can unmount the file system using the corresponding command that is part of the used FUSE package. Up to Ubuntu 20.04, this is fuse version 2 which contains the fusermount command, whereas since around Ubuntu 22.04, it has been replaced by fuse3 containing fusermount3 instead.

Therefore, on a modern Ubuntu release (22.04 or newer), the preferred method is to use:

fusermount3 -u <MOUNTPOINT>

Or in your specific example:

fusermount3 -u /temp/user/harddrive

For more info, see e.g. man sshfs and man fusermount or man fusermount3 for your respective Ubuntu release.

Byte Commander
  • 110,523
  • 5
    Note that the 17.10 and 18.04 manpages explicitly say “unmounting: umount mountpoint” while until 16.04 it’s fusermount -u mountpoint instead – guess it’s different for different releases! – dessert Jun 15 '18 at 18:59
  • This fails on Ubuntu 20.04 with the message: "fuse: bad mount point /temp/user/harddrive': Input/output error". I have never seen a sshfs get properly unmounted without using sudo`. – Luís de Sousa Oct 08 '20 at 09:09
  • sorry, no, it works fine: SSHFS immediately umounts with user rights if you follow the man page: fusermount3 -u mountpoint # Linux Actually it always works fine for me. RTFM. – opinion_no9 Apr 14 '24 at 12:55
  • 1
    @opinion_no9 You realize that the version of this answer you commented on is six years old and was accurate at the time of writing, right? No need to be snarky here. You're welcome to e.g. upvote newer answers or post one yourself, if you have anything significantly different to say compared to the existing posts. Or leave a polite comment suggesting an update to the answer instead. – Byte Commander Apr 15 '24 at 07:45
7

This answer refers to Ubuntu 20.04, but in general you need two steps to properly unmount a sshfs volume: i) kill the sshfs process and ii) use sudo to unmount. Without using sudo, the system reports messages like "Device or resource busy" or "Transport endpoint is not connected", even if permissions are correct.

The instructions look like:

killall sshfs
sudo umount -l /temp/user/harddrive
  • this is not the way. follow the man page: fusermount3 -u mountpoint for Linux and do not miss it is fusermount3 not umount. – opinion_no9 Apr 14 '24 at 12:58
5

Since I've bumped into this post and did not want to kill the process, just wanted to let you know that, as of Ubuntu 22.04, a simple umount works fine:

umount /mount/point/sshfs/folder

I did not get any warning or error message and the process was indeed terminated after checking with ps aux | grep ssh

  • it depends. from mounting in /etc/fstab the umount should work while fusermount3 is necessary without elevated rights and recommended by the man page. correct? – opinion_no9 Apr 16 '24 at 17:42
  • I'm on Ubuntu 22.04 and fusermount3 was failing with Device or resource busy but umount successfully unmounted. – abhishek47 Dec 06 '24 at 22:38