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

  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 192.168.0.0/24 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





CLIENT SIDE
Go to Client machine and check it out share is accessible

~]# showmount -e 192.168.234.132



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



Likewise you can provide the permissions to NFS share

Here are the most common NFS export techniques and options:
/home/nfs/ 192.168.234.123(rw,sync)
export /home/nfs directory for host with an IP address 192.168.234.123 with read, write permissions, and synchronized mode
/home/nfs/ 192.168.234.0(ro,sync)
export /home/nfs directory for network 192.168.234.0 with netmask 255.255.255.0 with read only permissions and synchronized mode
/home/nfs/ 192.168.234.123(rw,sync) 192.168.234.124 (ro,sync)
export /home/nfs directory for host with IP 192.168.234.123with read, write permissions, synchronized mode, and also export /home/nfs directory for another host with an IP address 192.168.234.124 with read only permissions and synchronized mode
/home/nfs/ 192.168.234.123 (rw,sync,no_root_squash)
export /home/nfs directory for host with an IP address 192.168.234.123with 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/ *.linuxcareer.com(ro,sync)
export /home/nfs directory for any host within linuxconfig.org 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




No comments:

Post a Comment