40

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
  • 12,914
  • 37
  • 45
  • 86
K.Wanter
  • 788
  • 2
  • 7
  • 15

3 Answers3

65

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

That also means you can not use umount (the counterpart of mount) to unmount the file system though, but you have fusermount -u, the FUSE unmount command:

fusermount -u /temp/user/harddrive

For more info, see e.g. man sshfs and man fusermount.

K.Wanter
  • 788
  • 2
  • 7
  • 15
Byte Commander
  • 105,631
  • 46
  • 284
  • 425
  • 4
    Note that [the 17.10 and 18.04 manpages](http://manpages.ubuntu.com/manpages/artful/en/man1/sshfs.1.html) 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
6

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
Luís de Sousa
  • 13,018
  • 25
  • 77
  • 128
0

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

soubaboy
  • 1
  • 1