KODI mount point

root v OpenELEC je připojený RO protože je to komprimovaný squashfs, který je sám o sobě RO fs. Existuje ale možnost, jak se s tím poprat. První možnost je přerazit defaultní nastavení pro /storage, které se předává jako parametr při bootu. Já mám celé /storage na NFS: disk=NFS=IP.AD.RE.SA:/export/xbmc/ Druhá je tu již několikrát zmíněna, tou je nastavení při startu: /storage/.config/autostart.sh A to, co uvnitř mám já:

#!/bin/sh (  #karta je nevyuzita, tak proc ne swap  swapon /dev/mmcblk0p2  # a mount sitoveho disku s videi a hudbou...  sleep 15; \  mount -t nfs IP.AD.RE.SA:/export/ /storage/export -o nolock; \ )&

…hotovo.

=============

New Method

Since OpenELEC 4.0.x you can now use systemd to control network mounts. It is a little more complicated, but makes it easy to enable and disable.

Systemd CIFS sample mount

/storage/.config/system.d/storage-music.mount

 [Unit]  Description=cifs mount script  Requires=network-online.service  After=network-online.service  Before=kodi.service   [Mount]  What=//192.168.0.31/Music  Where=/storage/music  Options=username=myusername,password=mypassword,rw  Type=cifs   [Install]  WantedBy=multi-user.target

And here is what all this means.

Description=test cifs mount script

↳ The description should be used to explain what this servicefile is for

Requires=network-online.service

↳ Network mounts *require* ‚network-online.service‘ which checks if the network is online

After=network-online.service

↳ Our scripts must start *after* ‚network-online.service‘, on timeout and if ‚network-online.service‘ fails we can not mount and this scripts fails too

Before=kodi.service

↳ Usually we mount networks shares because we want they available *before* Kodi starts. So Kodi has access to this mounts from beginning. Note: this slows down the boot!

What=//192.168.0.31/Music

↳ The share we want mount

Where=/storage/music

↳ Where we want mount this share

Options=username=myusername,password=mypassword

↳ Any options you usually use with the „-o“ parameter in the mount command

Type=cifs

↳ Filesystem type

WantedBy=multi-user.target

↳ The target is used by ‚systemctl enable ‚ to link this service to a runlevel for starting on boot. usually ‚multi-user.target‘ is ok here.

Slashes „/“ MUST BE REPLACED with dashes „-“ with .mount as extension. This means, if we want mount to „/storage/music“ (see above „Where=/storage/music“) then this file must be renamed to ‚storage-music.mount‘. This is only for the filename! not for the What= and Where= sections!

Enabling the CIFS mount

This mount can then be enabled via ssh with the command

systemctl enable storage-music.mount

Systemd NFS sample mount

/storage/.config/system.d/storage-movies.mount

[Unit] Description=test nfs mount script Requires=network-online.service After=network-online.service Before=kodi.service  [Mount] What=192.168.0.31:/movies Where=/storage/movies Options= Type=nfs  [Install] WantedBy=multi-user.target

And here is what all this means.

Description=test nfs mount script

↳ The description should be used to explain what this service file is for

Requires=network-online.service

↳ Network mounts *require* ‚network-online.service‘ which checks if the network is online

After=network-online.service

↳ Our scripts must start *after* ‚network-online.service‘, on timeout and if ‚network-online.service‘ fails we can not mount and this scripts fails too

Before=kodi.service

↳ Usually we mount networks shares because we want they available *before* Kodi starts. So Kodi has access to this mounts from beginning. Note: this slows down the boot!

What=192.168.0.31:/movies

↳ The share we want mount

Where=/storage/movies

↳ Where we want mount this share

Options=

↳ Any options you usually use with the „-o“ parameter in the mount command

Type=nfs

↳ Filesystem type

WantedBy=multi-user.target

↳ The target is used by ‚systemctl enable ‚ to link this service to a runlevel for starting on boot. usually ‚multi-user.target‘ is ok here.

Slashes „/“ MUST BE REPLACED with dashes „-“ with .mount as extension. This means, if we want mount to „/storage/music“ (see above „Where=/storage/music“) then this file must be renamed to ‚storage-music.mount‘. This is only for the filename! not for the What= and Where= sections!

Enabling the NFS mount

This mount can then be enabled via ssh with the command

systemctl enable storage-movies.mount

Notes

The CIFS mount may require a username/password to work. Test it via command line using the mount command first.

Old Method

If you don’t know Linux, then you can simply follow the guides below. From a Windows PC, open an explorer window and browse to the IP address of the OpenELEC machine. If you don’t know what the IP address is, go to the menu of the OpenELEC machine and click the „Info“ button on your remote control (or the i key). This will open a page that shows the IP address, so type this into the address bar of the explorer window. For example, if your IP address is 192.168.1.92, browse to:

 \\192.168.1.92

Once the window appears, open the Configfiles share. This will show you all the configuration files for your OpenELEC machine.

You create a file called autostart.sh (If it does not exist yet).

Open the file with a UNIX compliant text editor like notepad++ and use unix line endings. Windows‘ built-in editors like Notepad and Wordpad may cause problems, so don’t use them.

And copy the following code into the file:

 #!/bin/sh  (sleep 30;  COMMAND_THAT_RUNS;  )&

if you want to mount a cifs (samba) share replace COMMAND_THAT_RUNS with the following, substituting the ip, user and mountpoints by your own.

 mount -t cifs -o username=user,rw //10.0.0.101/music /storage/music

if you want to mount a nfs (Version 3) share replace COMMAND_THAT_RUNS with the following, substituting the ip and mountpoints by your own.

 mount -t nfs 10.0.0.101:/storage01/shared/music /storage/music -o nolock;

Example 1:

If we’re running a NAS or Linux server with an NFS share of /nfs/music, an IP address of 192.168.1.2 and we’re going to mount it at /storage/music we’ll have a autostart.sh that looks like:

 #!/bin/sh  (sleep 30;  mount -t nfs 192.168.1.2:/nfs/music /storage/music -o nolock;  )&

Example 2:

If we’re running a Windows server (or Linux server with SAMBA) with a share called tvseries, an IP address of 192.168.0.30 and we’re going to mount it at /storage/tvseries we’ll have a autostart.sh that looks like:

 #!/bin/sh  (sleep 30;  mount -t cifs -o username=user,rw //192.168.0.30/tvseries /storage/tvseries;  )&

There needs to be a username, ohterwise you will get a error when mounting.

Example 3:

Again, if we’re running a Windows server (or Linux server with SAMBA) with a share called tvseries, an IP address of 192.168.0.30 and we’re going to mount it at /storage/tvseries, but this time we need to use the username gilphilbert and the password mysecret we’ll have a autostart.sh that looks like:

 #!/bin/sh  (sleep 30;  mount -t cifs -o username=gilphilbert,password=mysecret,rw //192.168.0.30/tvseries /storage/tvseries;  )&

Example 4:

We want more then one share, in this case your autostart.sh will look like this:

 #!/bin/sh  (sleep 30; \  mount -t nfs 10.0.0.101:/storage01 /storage/nfs01 -o nolock;  mount -t nfs 10.0.0.102:/storage02 /storage/nfs02 -o nolock  )&

In the end reboot the machine and you can start using the share(s).

Example 5: Advanced

To use Wake On LAN (WOL) to make sure you server is up before Kodi starts, you can use the bootarguments

wol_mac=
wol_wait=

See, Boot Arguments for more details

Troubleshooting

nfsv3 vs nfsv4

If you are using nfsv3, your remote path might look like /storage01/somedir/stuff, if you are using nfsv4 it might look like /storage01

Update: NFSv4 is not supporten by OpenELEC, it needs idmapd to work…

 # mount -t nfs -o vers=4 server:/share /storage/share  mount: NFSv4 not supported  mount: mounting server:/share on /storage/share failed

Nothing Happens

Try running your mount command from the command line to see if that gives you any errors:

 mount -t nfs 10.0.0.102:/storage02 /storage/nfs02 -o nolock

If that doesnt work try running the autostart file from the command line, to see if you get any errors:

 cd /storage/.config  ./autostart.sh