Search code examples
linuxcommand-lineraspberry-pi2kodi

How to automount raspberry openelec sd on server


i need a simple command line(LINUX) for automount /storage/ Openelec SD card on a remote server when kodi start.

example

mount /storage/ 10.20.30.40/usernamefolder/

It's possible to make it running in background?

or create a connection for access on that SD in remote ssh.

Thank you


Solution

  • You could exchange ssh keys in a way your openelec root can issue the mount command on the remote server and the remote server can mount sshfs dirs of openelec. At e.g. the kodi run script you can run the mount command on the remote server.

    So you first need to create ssh keys. You can generate them on both the server and openelec with running

    ssh-keygen 
    

    as root. It may asks you if you want to overwrite, you do not have to. Copy the contents on both servers of

    /root/.ssh/id_rsa.pub
    

    and append (create new if it does not exist) to the file

    /root/.ssh/authorized_keys
    

    on the opposite system, so openelecs id_rsa.pub goes to authorized keys on the server and vice versa.

    Next step is to issue the mount command on startup from the openelec system on the remote server. To do so, edit the file

    /storage/.config/autostart.sh
    

    on the openelec and add following

    ssh <server> 'sshfs root@<openelec>:/storage /usernamefolder'
    

    This will obviously need sshfs on the remote server and you need to replace the values in the <> brackets. You can also if your openelec exposes nfs or samba or something else use something else to mount instead of sshfs. You could also add to the openelec shutdown script the corresponding umount.