SSHFS + systemd fails: Invalid argument

  • After installing the LibreELEC network-tools addon, I am able to successfully use the sshfs command in the CLI to mount a remote media directory. However, when attempting to use a systemd unit file to automatically mount the remote folder at boot, I receive an error. I am currently using the same options in unit files on several of my other machines, although they are using slightly newer versions of systemd.

    /storage/.config/system.d/storage-videos-Movies.mount

    Display Spoiler


    systemctl start storage-videos-Movies.mount

    systemctl status storage-videos-Movies.mount

    Display Spoiler


    Running the following command is successful:

    Display Spoiler
    Code
    sshfs -o reconnect,ServerAliveInterval=5,ServerAliveCountMax=3,IdentityFile=/storage/.ssh/id_ed25519_sshfs_user [email protected]:/files/Videos/Movies /storage/videos/Movies
  • No, the problem is with Type=fuse.sshfs.

    Seems sysetmd doesn't find sshfs correctly. I read somewhere that PATH is not transferred correctly and maybe systemd doesn't find sshfs.

  • Thanks CvH, I meant to remove uid & gid from this config since everything is root on LibreELEC. I also had tried before to remove all extraneous options from the config, but always received the same error.

    vpeter, I tried setting Type=auto and removing Type= entirely, but I'm getting the same systemctl status output as before.

    Incidentally, if I remove Type= and try the deprecated method of

    Code
    What=sshfs#[email protected]:/files/Videos/Movies

    the output of systemctl status is somewhat different:

    Display Spoiler

    I can confirm this directory definitely does exist:

    Display Spoiler
    Code
    LibreELEC:~ # ls -la /storage/videos/
    total 4
    drwxr-xr-x    4 root     root          1024 Aug 24 10:51 .
    drwxr-xr-x   15 root     root          1024 Sep  3 16:59 ..
    drwxr-xr-x    2 root     root          1024 Aug 24 09:26 Movies
  • Furthermore, changing the What= section to

    Display Spoiler
    Code
    What=/storage/.kodi/addons/virtual.network-tools/bin/sshfs#[email='[email protected]'][/email]:/files/Videos/Movies

    gets me one step further as I can actually see LibreELEC enter preauth with the remote server, but it still fails with systemctl status output of read: Connection reset by peer. So I do believe there is some truth to what you're saying about the PATH issues vpeter. However, it appears that something about the unit file is still not being interpreted correctly, as we're seeing the Connection reset by peer message.

    Edited 2 times, last by electricOzone (September 4, 2019 at 9:24 PM).

  • For the time being, I'm able to get things running by using autostart.sh. I would still prefer to use systemd, but if anyone else is in the same boat as me you should be able to use this method as well.

    /storage/.config/autostart.sh

    Display Spoiler
    Bash
    #!/bin/sh
    (sleep 5; \
      sshfs -o allow_other,default_permissions,reconnect,ServerAliveInterval=5,ServerAliveCountMax=3,IdentityFile=/storage/.ssh/id_ed25519_sshfs_user [email protected]:/files/Music /storage/music; \
      sshfs -o allow_other,default_permissions,reconnect,ServerAliveInterval=5,ServerAliveCountMax=3,IdentityFile=/storage/.ssh/id_ed25519_sshfs_user [email protected]:/files/Pictures /storage/pictures; \
      sshfs -o allow_other,default_permissions,reconnect,ServerAliveInterval=5,ServerAliveCountMax=3,IdentityFile=/storage/.ssh/id_ed25519_sshfs_user [email protected]:/files/Videos /storage/videos; \
      sshfs -o allow_other,default_permissions,reconnect,ServerAliveInterval=5,ServerAliveCountMax=3,IdentityFile=/storage/.ssh/id_ed25519_sshfs_user [email protected]:/files/zMultimedia /storage/zMultimedia; \  
    )&


    Should I post about this issue over in bug reports? Should this post be moved there? I'd like to avoid breaking any duplicate post rules :)

  • It is most likely this never will be fixed.

    The installed busybox mount does not support mount helper. Therefore the needed mount.fuse is not called for for the fuse.sshfs file system and the mount fails.

    Installing mount/unmount from util-linux should solve this. But sshfs will still not work because the binary is part of the addon and not in a standard path.

  • As per this, I was able to get the following to work:

    Though mount -t /storage/.kodi/addons/virtual.network-tools/bin/sshfs le-pi3:/var/media/external /var/media/test from the CLI after boot and:

    Code
    [Mount]
    What=le-pi3:/var/media/external
    Where=/var/media/test
    Type=/storage/.kodi/addons/virtual.network-tools/bin/sshfs

    both give me the "No such device" error.

    I'm using an ssh config file and haven't done any testing with Options.

    This is on a Raspberry Pi 4 (1gb) running 9.1.002.

    After typing this, I see you already tried What=/storage/.kodi/addons/virtual.network-tools/bin/sshfs#[host]:[path] in #5, so maybe it has something to do with the fact I'm using an ssh config file and/or not using any Options. I'll run a few tests on my end to see if I can replicate the "read: Connection reset by peer" error.

    Edit: As soon as I commented out my ssh config file and added the Options, I started getting the "read: Connection reset by peer" error. I was able to fix it by adding IdentifyFile back to my ssh config file. I should also note that the system doesn't recognize the hostname from the other Pi, so I also had to either use its IP directly or add Hostname back to my ssh config file, or I got the exact same error.

    Edited once, last by capntrips: updates after testing (September 10, 2019 at 9:19 AM).