Accessing Network Shares
Network shares some in two main forms. NFS[en.wikipedia.org/wiki/Network_File_System] and CIFS[www.samba.org/cifs/].
Contents
AutoFS
AutoFS is a simple means of mounting an external network share automatically when its required.
This method means that hard mounting in the fstab can be avoided such that if a share is not availalble at boot no errors are thrown.
Installing autoFS
sudo apt-get install autofs
Configure autoFS
Installation will create a configuration file /etc/auto.master
. Edit this file and add a link to a seperate file.
sudo nano /etc/auto.master
add the following at the end of the file.
/media/nfsshares /etc/auto.<fileservername> --ghost
where <fileservername> is then name of your fileshare server. make sure there's a return at the end of the line.
Create /etc/auto.<fileservername>
sudo nano /etc/auto.<fileservername>
add the local share folder name and the remote server address and location in the form
<localfolder> <server address>:/<server folder>
if you have numerous shares in the same tree, you can add something like this
* 192.168.0.8:/myshareroot/&
Test autoFS
first we need to restart the service
sudo service autofs restart
You should see
Stopping automount: done. Starting automount: done.
Navigate to the local share location, for example cd /media/nfsshares/music
List the contents of the directory to check its mounted, a brief delay as the folder is mounted may be expected depending on you network configuration.
cd /media/nfsshares/music ls
You should see a list of all the remote files.
If you get errors like 'directory not found', check your auto.master config.
Raspbian / Raspbmc
Problem
After installation and setup autofs doesn't work and access to an NFS directory results in
No such file or directory
this can be fixed by starting rpcbind
. To start rpcbind
manually.
sudo service rpcbind start [sudo] password for jack: [ ok ] Starting rpcbind daemon....
To run rpcbind
at startup.
sudo update-rc.d rpcbind defaults sudo update-rc.d rpcbind enable
Re-boot the RPi and test.