You are not logged in.

#1 2018-08-03 12:21:44

kaifis
Member
Registered: 2016-12-22
Posts: 58

How to use sshfs such that it won't freeze after disconnect.

Hey,
I'm trying to achieve this for two days and I cannot find anything. I want the sshfs to stop freezing system calls 3 seconds after host disconnects and to try to reconnect every 30 secs while the connection is closed (power outage and other causes for short-term server unavailability). I feel like this can be achieved by just the right options for sshfs but I cannot figure out which ones.

Archwiki doesn't mention this issue at all (just how to connect at boot or on demand) and google found just this solution (and more others but with the same solution):
askubuntu: https://askubuntu.com/questions/716612/ … 618#716618

sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 server:/path/to/mount

This will limit the time that program freezes to 1 minute. I have set

ServerAliveInterval=1, ServerCountMax=3

But it doesn't feel like a thing I was ment to do. And moreover, this will stop all efforts to reconnect after 3 seconds. So I will need to create some callback scripts that will try to remount sshfs every 30 secs. That could work but there probably is a way to achieve this without adding this feature without adding complexity connected with callback script.

Last edited by kaifis (2018-08-03 12:22:29)

Offline

#2 2018-08-03 12:54:08

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,412
Website

Re: How to use sshfs such that it won't freeze after disconnect.

But it doesn't feel like a thing I was ment to do.

Why? If you want to reconnect, use autossh.


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#3 2018-08-18 01:28:31

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: How to use sshfs such that it won't freeze after disconnect.

I feel there is misunderstanding about ServerAliveInterval setting, as per the sshfs manual

SSHFS hangs
       In  some  cases, attempts to access the SSHFS mountpoint may freeze if no filesystem activity has occured for some time. This
       is typically caused by the SSH connection being dropped because of inactivity without SSHFS being informed about that.  As  a
       workaround, you can try to mount with -o ServerAliveInterval=15. This will force the SSH connection to stay alive even if you
       have no activity.

So reducing ServerSliveInterval is actually bad thing if you want to avoid freezing.

Are you using sshfs through /etc/fstab ?? It may be a cause of freezing as file manager will wait for sshfs to be mounted.

Last edited by Docbroke (2018-08-18 01:29:58)

Offline

#4 2018-08-18 16:01:58

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,412
Website

Re: How to use sshfs such that it won't freeze after disconnect.

The misunderstanding is entirely on your part.

The point of the paragraph you quoted is This will force the SSH connection to stay alive even if you have no activity., where This refers to ServerAliveInterval that is not activated by default (set to 0). The 15 is an example parameter and can be set according to preference.

You might want to read man ssh_config for details.

Last edited by Alad (2018-08-18 16:03:34)


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

Board footer

Powered by FluxBB