Network File system

   Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a network much like local storage is accessed.

Service Profile:              nfs and portmap
Configuration File:       /etc/exports
Port Number:                2049 portmap: 111
Log File:                         /var/log/messages
Versions available:  Version 2, 3 & 4

NFS v3 Vs NFS v4

Export Management

  1. In NFSv3, client must rely on auxiliary protocol, the mount protocol to request a list of server’s exports and obtain root filehandle of a given export. It is fed into the NFS protocol proper once the root filehandle is obtained.
  2. In NFSv4 uses the virtual file system to present the server’s export and associated root filehandles to the client.
  3. NFSv4 defines a special operation to retrieve the Root filehandle and the NFS Server presents the appearance to the client that each export is just a directory in the pseudofs
  4. NFSv4 Pseudo File System is supposed to provide maximum flexibility. Exports Path name on servers can be changed transparently to clients.

  1. NFSv3 is stateless. In other words if the server reboots, the clients can pick up where it left off. No state has been lost.
  2. NFSv3 is typically used with NLM, an auxiliary protocol for file locking. NLM is stateful that the server LOCKD keeps track of locks.
  3. In NFSv4, locking operations are part of the protocol
  4. NFSv4 servers keep track of open files and delegations
Blocking Locks

  1. NFSv3 rely on NLM. Basically, Client process is put to “sleep”. When a callback is received from the server, client process is granted the lock.
  2. For NFSv4, the client to put to sleep, but will poll the server periodically for the lock.
  3. The benefits of the mechanism is that there is one-way reachability from client to server. But it may be less efficient.

To configure NFS share we have to install below packages
~]#rpm -qa |grep nfs

Nfs-utils are installed in my system, if there is no nfs-utils in your server please install
~]# yum install nfs*

# yum install xinet*

Start NFS, Portmap and Xinetd services
~]# service portmap restart
~]# service xinetd restart 

 NFS uses tcp_wrappers for additional security. The service for tcp_wrappers is portmap. Add an entry to /etc/hosts.allow to allow the subnet access to NFS service.

~]# service nfs restart

Verify the port nfs is working
~]# rpcinfo -p |grep nfs

Share the directory or disk using NFS

To sharing the Directory/Disk we have edit the /etc/exports and add the entries

Go to Client machine and check it out share is accessible

~]# showmount -e

Now mount the share to your local mount point
~]# mount -t nfs /mnt

Likewise you can provide the permissions to NFS share

Here are the most common NFS export techniques and options:
export /home/nfs directory for host with an IP address with read, write permissions, and synchronized mode
export /home/nfs directory for network with netmask with read only permissions and synchronized mode
/home/nfs/,sync) (ro,sync)
export /home/nfs directory for host with IP read, write permissions, synchronized mode, and also export /home/nfs directory for another host with an IP address with read only permissions and synchronized mode
/home/nfs/ (rw,sync,no_root_squash)
export /home/nfs directory for host with an IP address read, write permissions, synchronized mode and the remote root user will be treated as a root and will be able to change any file and directory.
/home/nfs/ *(ro,sync)
export /home/nfs directory for any host with read only permissions and synchronized mode
/home/nfs/ *,sync)
export /home/nfs directory for any host within domain with a read only permission and synchronized mode
/home/nfs/ foobar(rw,sync)
export /home/nfs directory for hostname foobar with read, write permissions and synchronized mode

Mounting NFS share as permanent, we have to edit /etc/fstab, if you want restart and verify the mount point

~]# mount –a                           - To refresh the mount points
 To remove nfs share we have to un-mount the share from client machine
~]# umount /mnt

Remove entry from /etc/fstab file