This guide will show you how to access media from your NAS on your OpenELEC computer and make them permanently available.

Only use this method if you absolutely need too. Kodi provides mounting network filesystems (nfs, smb, etc) natively and is the preferred method!

OS level mounts are only needed for saving PVR recordings to a network location or using a downloader (rtorrent, transmission, etc) to download to a network location.

For information about Kodi network mounts see the kodi.wiki for information about media sources and the list of available media types.

This guide will show you how to access media from your NAS on your OpenELEC computer and make them permanently available.

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.

/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.

This mount can then be enabled via ssh with the command

systemctl enable storage-music.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.

This mount can then be enabled via ssh with the command

systemctl enable storage-movies.mount

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

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.

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;

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;
 )&

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.

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 my_name and the password my_secret we'll have a autostart.sh that looks like:

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

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).

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

wol_mac=<mac-address>

wol_wait=<seconds>

See, Boot Arguments for more details

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

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

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