Linux – Can’t access folders mounted by sshfs after sleep (or when connection lost)

arch linuxlinuxmountsshfs

Often, when I mount a filesystem via ssh:

sshfs user@remote: ~/Mounts/Remote

and the machine hibernates (closing the Laptop lid) if I wake up the machine I can't access the mounted folder. Furthermore, if I try to ls in the parent folder, the terminal freeze. The same also happens when the connection is somehow lost.

If try to unmount using

fusermount -u ~/Mounts/Remote

I can't do this because:

fusermount: failed to unmount /home/yotama9/Mounts/Remote: Device or resource busy

I tried to kill ssh but I can't mount the folder again. ls in the folder still freezes.

How can I avoid this and fix this (Arch Linux)?

Best Answer

I suffer the same problem in Ubuntu Linux. What I do after resume:

$ killall -9 sshfs

Then, umount

$ fusermount -u ~/far_projects

and mount again the remote filesystem.

$ sshfs -o idmap=user youruser@server:/projects ~/far_projects
Related Question