NFS Configuration

NFS (Network File System) is used to sharing the files and folders between linux to unix and unix to linux machines,NFS was  developed by Sun Mycro Systems in the year 1984.
1. Every one can access same data.
2. Reduce Storage Cost and Easy to use.
3. Centralized Management of Files.
4. Secured with Firewalls and Kerberos.
NFS Configuration :
NFS Port Number      :    2049
Service Name            :    nfs
Packages                   :    nfs-utils & nfs-utils-lib
/etc/exports  :  It is main Configuration file of NFS, define all                                                      exported files and folders in this path.
/etc/sysconfig/nfs  :  It is also Configuration file of NFS to controle on which port rpc
and other services are listening.
To setup NFS Server, we have at least two Linux Machines.In this article we will be using two machines, one is NFS Server and  another one is NFS Client
NFS Server    :
NFS Client      :
Server Side Configuration(
Configure Server machine ( using below steps
Step 1:  Install NFS Packages & start services
Install NFS Packages using yum command

[root@bsrtech ~]# yum install  nfs-utils nfs-utils-lib -y

start nfs service

[root@bsrtech ~]# service nfs start
[root@bsrtech ~]# chkconfig nfs on

(By using chkconfig for every reboot this services automatically starts)
Step 2 : Configure Shared Folders

[root@bsrtech ~]# vim /etc/exports
      syntax : <share directory>  <clients range> <permissions>
         ex  : /nfsdata,sync)

save and quit
rw    :  read & write permissions of /nfsdata folder
sync : sync confirms requests to the shared directory only once the changes have  been  committed.
After changes , restart service

[root@bsrtech ~]# service  nfs  restart

By default kernel will read root_squash means anyone who wants to access /nfsdata comes under others.So we have to change permissions of /data as readwrite to others.

[root@bsrtech ~]# chmod 777 /nfsdata

Note : By giving like this there is no security and any file created by users under /nfsdata should get the owner and group ownership to nfsnobody.
To prevent this one provide no_root_squash in /etc/exports

[root@bsrtech ~]# vim /etc/exports

save and quit (:wq)
Change permissons of /nfsdata folder

[root@bsrtech ~]# chmod 750 /nfsdata
[root@bsrtech ~]# service nfs restart

Create some files in shared directory

[root@bsrtech ~]# cd /nfsdata
[root@bsrtech nfsdata]# touch f1 f2 f3 f4

Client Side Configuration (
Configure Client machine ( using below steps
Step 1: Install NFS Packages & start NFS service
Install NFS Packages using yum command

[root@nfsclient ~]# yum install  nfs-utils nfs-utils-lib -y
[root@nfsclient ~]# service nfs start
[root@nfsclient ~]# chkconfig nfs on

Step2 : To findout which files or directories are exported from the server

  [root@nfsclient ~]# showmount -e

where is server ip address
Step3 : Mount shared NFS Directory
Mount Sahred NFS directory using mount command, first create folder for mount point

[root@nfsclient ~]# mkdir /mnt/nfsdata
[root@nfsclient ~]# mount -t nfs   /mnt/nfsdata
[root@nfsclient ~]# mount

Verify above mount point using mount command
The above mount command mounted the  nfs shared directory on to nfs client on temporarily, to mount permanently write in /etc/fstab see below

[root@nfsclient ~]# vim /etc/fstab /mnt/nfsdata  nfs defauls 0 0

step 4 : Check the shared files & folders
Move to shared mounted directory

[root@nfsclient ~]# cd /mnt/nfsdata[root@nfsclient nfsdata]# ls
f1  f2  f3  f4

(these are shared files from nfs server machine)

Leave a Reply

Your email address will not be published. Required fields are marked *