Automount sshfs using fstab without mount -a
Solution 1:
The correct syntax for mounting sshfs shares at boot, in the /etc/fstab file is
USERNAME@HOSTNAME_OR_IP:/REMOTE/DIRECTORY /LOCAL/MOUNTPOINT fuse.sshfs _netdev,user,idmap=user,transform_symlinks,identityfile=/home/USERNAME/.ssh/id_rsa,allow_other,default_permissions,uid=USER_ID_N,gid=USER_GID_N 0 0
It is an adaptation to non-systemd distros of the instructions contained here. If you are instead on a systemd distro (Arch, Fedora, OpenSUSE,...), the suitable instruction is:
USERNAME@HOSTNAME_OR_IP:/REMOTE/DIRECTORY /LOCAL/MOUNTPOINT fuse.sshfs x-systemd.automount,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/USERNAME/.ssh/id_rsa,allow_other,default_permissions,uid=USER_ID_N,gid=USER_GID_N 0 0
Solution 2:
Try using the delay_connect option.
Full /etc/fstab line:
USER@HOSTNAME:/REMOTE/ /LOCAL/ fuse.sshfs delay_connect,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/USERNAME/.ssh/id_rsa,allow_other,default_permissions,uid=USER_ID_N,gid=USER_GID_N 0 0
Solution 3:
Those delay_connect
, _netdev
, ... are correct but won't work unless you tweak the networking to come up exactly in (or before) that small time window, when the /etc/fstab is being processed. When the processing is over, and networking comes up later, you have to use the mount -a
(or friends).
In most cases (and mine also) the network-manager
caused the problem, since it brings the network up after login by default. It can be tweaked to bring it up earlier at boot time. If I remember correctly, all you need to do is to check the option Available to all users
in the connection properties dialog (or, if you prefer command line, create manually the connection in /etc/NetworkManager/system-connections
).