Table of Contents

NFS Shares

Installation

# apt-get install nfs-kernel-server

Config the shares on the host

Edit /etc/exports and add a line for each share:

/share 192.168.1.0/24(rw,sync,no_subtree_check)
/media 192.168.1.0/24(rw,sync,no_subtree_check,all_squash,anonuid=1000,anongid=100)

The first line is an example for a data directory. Note that uid and gid need to match on the client and the server, otherwise you might run into permission issues. The second line is an example for a media directory, e.g. for music or video files shared by the server. To make the the respective processes be able to access the shared media files, use a user on the system with the same uid and gid on client and server, and add group membership to the media process.

Set your shared directory with user root and group users. Set the set-gid bit so all clients create directories and files with the same (users) group.

chmod 770 /share
chmod g+s /share
chown root.users /share

Then, add your user from the client to the users group. Remember, that numerical uid's are passed, not names. It is therefore best to have the same uid on the client and the server machine.

vim /etc/group

Access permanent shares from the client

Create the mount point:

mkdir /mnt/share

Add the following line to the fstab file on the client:

server:/share  /mnt/backup  nfs  _netdev,rsize=32768,wsize=32768,intr,noatime  0  0

Access temporary shares from the client

mount -t nfs <computername>:/path-to-share /mount-point

Access shares from a Windows 7 client

Note: Client for NFS feature is only available on Windows 7 Ultimate Edition and Enterprise Edition.

The Client for NFS is included in the Windows 7, however, it is turned off by default. You can turn it on by accessing Control Panel → Programs → Programs and Features → Turn Windows features on or off. Find Services for NFS and enable all features.

Set the “default” anonymous UID and GID for Client for NFS to access a NFS share:

  1. Open the Run box and start Registry Editor by running command regedit
  2. Locate HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default
  3. Add two DWORD32 values: AnonymousUid and AnonymousGid
  4. Set theses values to the UID and GID on your Linux box, which is owner and group of the shared directory. In the most popular cases, they are 1000 and 100 decimal.
  5. Restart computer

Open Computer (or press Windows + E), click Map netwok drive on the toolbar and enter the NFS share in the Folder text box.

Articles