Difference between revisions of "Accessing Network Shares"

From SingletonMillerWiki
Jump to: navigation, search
(Problem)
m (added troubleshooting tip)
 
(10 intermediate revisions by 2 users not shown)
Line 78: Line 78:
 
</pre>
 
</pre>
  
To run <code>rpcbind </code> at startup.
+
The preferred methid is to run <code>rpcbind </code> at startup.
  
 
<pre>
 
<pre>
Line 86: Line 86:
  
 
Re-boot the RPi and test.
 
Re-boot the RPi and test.
 +
 +
== Autofs for LDAP ==
 +
 +
The following method allow auto mounting of any CIFS shares and retains the users permissions.
 +
 +
<pre>
 +
$tail /etc/auto.master
 +
# Include central master map if it can be found using
 +
# nsswitch sources.
 +
#
 +
# Note that if there are entries for /net or /misc (as
 +
# above) in the included master map any keys that are the
 +
# same will not be seen as the first read key seen takes
 +
# precedence.
 +
#
 +
#+auto.master
 +
/media/nfsshares /etc/auto.ldapcifs --ghost
 +
</pre>
 +
 +
edit the server specifics, replace <code><cifs server></code> with your server name or address
 +
<pre>
 +
$cat /etc/auto.ldapcifs
 +
* -fstype=cifs,rw,credentials=${HOME}/cifs.cred,uid=${UID},gid=${UID} ://<cifs server>/&
 +
</pre>
 +
My LDAP server doesn't have group ID for each user, instead the default is 'Domain Users', therefore in order to ensure the permissions are retained I actually use a fixed <code>gid=1000000</code>. You system my use a different ID.
 +
 +
Change the new file permissions, this shouldn't necessary, but I do it for good measure.
 +
<pre>
 +
$sudo chmod 0644 /etc/auto.ldapcifs
 +
</pre>
 +
 +
=== User Specific Actions ===
 +
Create a credential file for each user, this should be done by each user when they first login
 +
<pre>
 +
$cat ~/cifs.cred
 +
username=jack
 +
password=<jacks cifs password>
 +
</pre>
 +
 +
then they should hide the credentials file.
 +
<pre>
 +
$chmod 600 /home/jack/cifs.cred
 +
</pre>
 +
 +
== Troubleshooting ==
 +
Trying installing <code>cifs-utils</code>.
 +
 +
== References ==
 +
#[https://help.ubuntu.com/community/Autofs#CIFS https://help.ubuntu.com/community/Autofs#CIFS]
 +
#[http://ubuntuforums.org/showthread.php?t=1494525 http://ubuntuforums.org/showthread.php?t=1494525]

Latest revision as of 14:55, 2 September 2013

Network shares some in two main forms. NFS[en.wikipedia.org/wiki/Network_File_System] and CIFS[www.samba.org/cifs/].

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

The preferred methid is to run rpcbind at startup.

sudo update-rc.d rpcbind defaults
sudo update-rc.d rpcbind enable

Re-boot the RPi and test.

Autofs for LDAP

The following method allow auto mounting of any CIFS shares and retains the users permissions.

$tail /etc/auto.master
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
#+auto.master
/media/nfsshares /etc/auto.ldapcifs --ghost

edit the server specifics, replace <cifs server> with your server name or address

$cat /etc/auto.ldapcifs
* -fstype=cifs,rw,credentials=${HOME}/cifs.cred,uid=${UID},gid=${UID} ://<cifs server>/&

My LDAP server doesn't have group ID for each user, instead the default is 'Domain Users', therefore in order to ensure the permissions are retained I actually use a fixed gid=1000000. You system my use a different ID.

Change the new file permissions, this shouldn't necessary, but I do it for good measure.

$sudo chmod 0644 /etc/auto.ldapcifs

User Specific Actions

Create a credential file for each user, this should be done by each user when they first login

$cat ~/cifs.cred
username=jack
password=<jacks cifs password>

then they should hide the credentials file.

$chmod 600 /home/jack/cifs.cred

Troubleshooting

Trying installing cifs-utils.

References

  1. https://help.ubuntu.com/community/Autofs#CIFS
  2. http://ubuntuforums.org/showthread.php?t=1494525