Friday, January 1, 2021

How to configure NFS Server

 

Package of nfs


                          Package                   : nfs*
                          Daemons                 :rpc.nfsd, rpc.mountd, rpc.statd, rpc.lockd
                                                           rpc.rquotad
                          Script                     :     /etc/init.d/nfs  
                          Port number           :    2049
                          Configuration File  :    /etc/exports

                          Other imp files       :   /var/lib/nfs/etab, /var/lib/nfs/rmtab


Steps to configure NFS server:

Step1: Install the NFS package using yum or rpm.

                      root@server~#yum install nfs* -y

Step2: Create a  directory on partition and add some data in it.

                       root@server~#fdisk   /dev/sda

Step3: Export the directory by editing /etc/exports file and using exportfs command
                      root@server~#mkfs.ext4 /dev/sda1

                      root@server~#chmod 777   /nfs_share_dir
                      root@server~#mount  /dev/sda1 /dev/nfs_share_dir
                      root@server~# chcon -t public_content_t  /nfs_share_dir

Step4:  The mount point and add some data in it
                      root@server~#cd   /dev/nfs_share_dir

                      root@server~#touch file{1..5}
 
                      root@server~#cd   /dev/nfs_share_dir

Step5: Export the directory
                      root@server~#vim /etc/exports
                                                /dev/nfs_share_dir   192.168.0.10 (rw,sync)
Step6: Execute exportfs command
                        root@server~#exportfs –avr

Step7:Restart the services
                          root@server~# systemctl restart nfs-server
Step8:Add firewall services
                          root@server~# firewall-cmd  --permanent  -add-service=nfs
                                                                 (to enable the nfs service at firewall)
                          root@server~# firewall-cmd --permanent -add-service=mountd
                                                                  (to enable the mountd service at firewall)
                          root@server~# firewall-cmd --permanent -add-service=rpc-bind
                                                                (to enable the rpc-bind service at firewall)
                          root@server~# firewall-cmd --complete-reload

Client side configuration for NFS mounting



Step1:Install the NFS package if not installed
                       root@client~#rpm –q nfs

Step2:Start the NFS services
                        root@client~#systemctl restart  nfs

Step3:Start the NFS services
To check the exported directories from server

                       root@client~#showmount –e  192.168.0.10

Step4: Make a directory

                       root@client~#mkdir /nfsclient

Step5:  mount NFS .

     root@client~#mount –t nfs 192.168.0.10:/dev/nfs_share_dir  /nfsclient


Note:
(i)NFS does not support cross plat forms. it will not support the sharing the files between Linux and  Windows systems.
(ii) NFS does not support encryption of the data and it supports only plain text format.


No comments:

Post a Comment