NFS(Network File System) is basically developed for sharing of file and folders between Linux/Unix system by Sun Microsystem in 1980.it allows you to mount your local file system over a network and remote host to interact,with them as they are mounted locally on the same system.with the help of NFS,we can set up file sharing between UNIX to Linux system and Linux to UNIX system.
The NFS server package includes three facilities,included in theportmap and nfs utils package.
1.portmap - It maps calls made from other machines to the correct RPC(Remote Procedure Call) service(not required with NFSv4).
2.nfs - it translates remote file sharing requests into requests on the local file system.
rpc.mountd - this service is responsible for mounting and unmounting of file system.
To setup NFS mounts,we'll be needing at least two Linux/Unix machines using two servers.
we need to install NFS package on our NFS Server as well as on NFS Client machine.we can install it via "yum"(Red Hat Linux) and "apt-get"(Debian and Ubuntu)package installers.
[root@nfsserver ~]# yum install nfs-utils nfs-utils-lib
[root@nfsserver ~]# yum install portmap (not required with NFSv4)
[root@nfsserver ~]# apt-get install nfs-utils nfs-utils-lib
Setting up the NFS Server
First we will be configuring the NFS server
Configure Export directory
for sharing a directory with NFS,we need to make an entry in "/etc/exports" configuration file.here be creating a new directory named "nfsshare" in "/" partition to share with client server,you can also share an already existing directory with NFS.
[root@nfsserver ~]# mkdir /nfsshare
[root@nfsserver ~]# vi /etc/exports
/nfsshare 169.60.0.01(rw,sync,no_root_squash)
in this above example,there is a directory in / partition named "nfsshare" is being shared with client IP "169.60.0.01" with read and write(rw) privilege,you can also use hostname of the client in the place of IP in above example.