Network File System Sharing is used for sharing the files/directory all through the network

port 2049

files used are
rpc.nfsd
rpc.mountd
rpc.lockd
rpc.statd
rpc.rquotandd

@ /usr/sbin
/etc/init.d/nfs
/etc/init.d/nfslock
/etc/exports

1.Server — place from which we need to share the directory

—->yum install -y nfs-utils*
—->service nfs restart
—->chkconfig nfs on
—->vim /etc/exports

In this file we say about files we need to share ,the mode in which the files are to shared and network to which the files are to be shared

eg:
/nfs 192.168.0.0/24(ro)
/nfs 192.168.122.0/255.255.255.0(rw,sync)
/nfs 192.168.122.0/24(ro)
some of the modes in which directories can be shared are
crossmnt
no_subtree_check
root_squarch

—->exportfs -r

—-****we should set the proper context ,sebool and setfacl for needed user

—->getsebool -a | grep nfs

this will list the needed Boolean we must set it according to the needs

—->setfacl -m u:nfsnobody:rwx /nfs

this will allow the nfsnobody user to use the /nfs directory this is needed if we are giving the write option to the directory

if more problems occur while sharing the directory we should also check the context for selinux or disable the selinux

showmount -e 192.168.0.1
will list the all the nfs shared directory by the server 192.168.0.1

2.Client — where we will mount the shared directories
there are multiple ways to mount the directory

—->yum install -y nfs*
—->service nfs restart
—->chkconfig nfs on

a.every shared folders will be available at /net every time as readonly type we use that as following ,for first example of sharing

—->cd /net
—->cd 192.168.0.1 cd nfs

b.We can also mount the directory by simple mount command
mount nfs://192.168.0.1/nfs /data

one of the main default of this system is that if we give the entry for mount in fstab and server goes down and if we restart the client ,the client will have boot break to over come this problem we use autofs mounting systems

c.using autofs mounting system

here first we will edit /etc/auto.master file

—->vim /etc/auto.master

/data /etc/auto.nfs

—->vim /etc/auto.nfs

nfs -rw 192.168.122.1:/nfs

—–>service autofs reload
—–>chkconfig autofs on

here after reloading the autofs service we could browse to that folder
—->cd /data
—->cd nfs
—->ls