Mounting network shares

From OpenELEC
Jump to: navigation, search

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

To mount files, we need to get access to your configuration files on the OpenELEC files.

Fortunately, OpenELEC shares this folder so you can access it from your computer (unless you've removed it previously).

If you have experience with Linux, you can use SSH to open a terminal to your OpenELEC machine (there are guides on how to do this elsewhere on the site); the configuration files are held in /storage/.config and you can use vi or nano to edit them.


Contents

OpenELEC 2.0

Ever since preEden the netmount.conf is no longer used. If you want to mount, you can use the autostart.sh file (You can also use this file to automate other things at startup).

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 | Textpad. 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 4) share replace COMMAND_THAT_RUNS with the following, substituting the ip and mountpoints by your own.

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

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

Here we do something a little more creative. we try to ping the server until it answers and then mount. Shares will be mounted under /media/share1 and so on...

Change the server and shares variables to your server and shares settings.

 #!/bin/sh
 n=1
 
 server=192.168.1.1
 shares="share1 share2"
 # can be nfs for nfs or cifs for samba or windows shares
 type=nfs
 
 until ping -w 1 -c 1 "$server" &>/dev/null ;do
   sleep 1
   n=$(( n+1 ))
   [ $n -eq 30 ] && break
 done
 for share in $shares ;do
   [ -d /media/$share ] || mkdir -p /media/$share
   if [ $type == cifs ];then
     mount -t $type //$server/$share /media/$share
   elif [ $type == nfs ];then
     mount -t $type $server:/$share /media/$share
   fi
 done
 ln -sf /media /storage/media

Notice that here we dont use the ( ... )& that is because we want the shares mounted before xbmc starts.

Note on cifs: if you use cifs share you might need to add the username= and password= options from above, joust add them to the cifs mount command.

a link is created from /media to /storage/media

Linux Commandline help (Mostly Eden)

Lets say we want to mount 2 nfs shares in the 2 following locations:

 /storage/nfs01
 /storage/nfs02

First you login to your openelec machine, using ssh.


Then you do the following:

 cd /storage
 mkdir nfs01
 chown openelec:openelec nfs01 (Not sure about this one but its working for me, might also work with just root being the owner.)
 mkdir nfs02
 chown openelec:openelec nfs02 (Same as above)

Next check if the autostart.sh file is already in place or not:

 cd /storage/.config
 ls -la

This wil give you a list of files in the .config directory.

If the autostart.sh file is already there do:

 vi autostart.sh

Else do:

 touch autostart.sh
 chmod +x autostart.sh
 vi autostart.sh

If you know vi, then just make the file look like you want, an example is shown below.

If you don't know vi, then press "i" and paste the example in there, then press "ESC", then press shift ":", you will get a commanline like thing, at the bottom of your screen, enter "w" and press <enter>. Press shift ":" again, in the commandline like thing enter "q" and press <enter>. This will save and quit the file.

autostart.sh sample (For more exaples see the Eded/Frodo howto):

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

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 happends

Try running your mount command from the commandline 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 commandline, to see if you get any errors:

 cd /storage/.config
 ./autostart.sh

Catagory:Configuration

Personal tools
Namespaces
Variants
Actions
Donate
Navigation
Wiki help
Toolbox