How to (cleanly) dismount sshfs when mounted on a NFS mount point?
Solution 1
You should be able to unmount the sshfs share by executing:
fusermount -u /path/to/sshfs/share
Solution 2
Just kill the process using pkill to and then un mount the mounted folder path.
pkill -kill -f "sshfs" && umount /path/to/sshfs/share
Solution 3
This post is rather old. Currently on RHEL8, this is all that is required. There is no need to kill sshfs processes:
sudo umount <mountpoint>
Related videos on Youtube
Daniel Böhmer
Updated on September 18, 2022Comments
-
Daniel Böhmer over 1 year
My coworker has a desktop computer with
/home
shared on our file server. I have developed a Perl script forsshfs
-mounting a certain directory on another SSH host which works fine on my laptop.On his computer the script fails to dismount the
sshfs
at the end and leaves the mountpoint unclean. I didn't find any way to recover the mountpoint other than rebooting. After some testing I found that the difference between our setups is that his/home
is on NFS. In his/tmp
it works flawlessly.After mount, during script operation everything is fine. But when killing the
sshfs
process it is listed as<defunc>
byps
until the parent process (the Perl script) exits. When running a rawsshfs
command on the shell the problem still occurs.A
ls -dl
output for the mountpoint looks like this (as remembered - I have no real copy of the shell output at hand):? 1 ? ? 4096 Feb 9 15:37 file_archive/
(only question marks for most information, at least all permission details)
The sshfs mount is still listed by
mount
but an unmount operation fails with error permission denied even when doing asroot
.I searched Google but only found lots of comparisons between sshfs and NFS for running network filesystems. How can I do a sshfs mount/unmount in NFS directory safely?
-
Daniel Böhmer almost 13 yearsI tried this but got permission denied. Of course an ordinary
umount
must fail when run as non-root user. -
fixer1234 over 8 yearsCan you expand your answer to explain what this code does and how it addresses the problem? Unexplained code is discouraged, because it doesn't teach the solution. Thanks. from review queue
-
Dessa Simpson over 6 yearsThis is for OS X. The question asked for Linux.
-
fchen over 5 yearsSometimes I have to do "sudo umount -f" or "sudo umount -l" instead of umount.
-
JFlo over 5 yearsMost likely the reason you can't unmount (with any method) is because his home dir is mount from NFS where it's exported with the
root_squash
option. Thus, root has no authority in his home dir. You might turn offroot_squash
but it's probably safer to just mount somewhere else. -
MacMartin over 5 yearsI forget everytime, that
umount
orfusermount -u
doesnt work, when the directory is used somewhere. Socd
out of the directory before usingfusermount -u
or uselsof /my/local/mountpoint
-
Luís de Sousa over 3 yearsThis returns the following error message: "umount: /path/to/sshfs/share: Transport endpoint is not connected"
-
Luís de Sousa over 3 yearsReturns an error message: "fuse: bad mount point `/path/to/sshfs/share': Input/output error"