Loading...
Advance Linux

NFS Server

NFS Server Configuration:
NFS service Port Number : 2049
  • The network File System is certainly one of the most used network services.
  • NFS is based on the Remote procedure call.
  • It allows the client to automount and transparently access the remote file systems on the network.
  • Using NFS we can share the files among homogenous environment hence, we can’t share the files between unix to windows environment.
  • NFS was developed by Sun Micro Systems.
  • NFS was developed to allow the user to access remote directory as a mapped directory.
  • NFS is not a single program. It is a suit of related programs

Features:

  • Every one can access same data this eliminates the need to have a redundant data on server systems.
  • Reduces storage cost.
  • Provides data consistency.
  • Reduces the system the system administrator overhead.
  • Data transfer rate in 3.0 is 32 kb bit but in 2.0 it is only 8 kb.

Prerequisites:

(i) Verify NFS daemon Service:
Here we assume that the NFS Service daemon is already on our system, include port map daemon on which NFS setup depends. One more thing, our system need to support the NFS file system. For this we needs to issue the following command:

#cat    /proc/filesystems

Another way to check NFS functioning

#rpcinfo     -p

(ii) Server export file:
All NFS Server export need to be defined in /etc/exports file.

(a) /home/nfs/ 192.168.1.254 (rw, sync):
Export /home/nfs directory for host with IP 192.168.1.254 with read, write permissions and synchronized mode

(b) /host/nfs 192.168.1.254 (ro, sync):
Export /home/nfs directory for network 192.168.1.254 netmask 255.255.255.0 with read only permissions and synchronized mode.

(c) /home/nfs/ 192.168.1.254 (rw, sync, ro_root_squash):
Export /home/nfs directory for host with IP 192.168.1.254 with read, write permission, synchronized mode and the remote root user will be treated as a root and will be able to change any file and directory.

(d) /home/nfs * (ro, sync):
Export /home/nfs directory for any host with a read only permission and synchronized mode

(e) /host/nfs * . wisdome.com (rw, sync):
Export /home/nfs directory for any host within wisdom.com domain with read, write permissions and synchronized mode.

To Install NFS packages and utils in NFS Server use below commands

 yum install nfs-utils nfs-utils-lib  -y 
 systemctl enable nfs-server.service 

Beofre starting nfs service start rpc bind service

systemctl start rpcbind
systemctl start nfs-server.service
systemctl status nfs-server.service
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload 
mkdir /NFSSHARE
chown  nfsnobody:root /NFSSHARE
chmod -R 775 /NFSSHARE
cd /NFSSHARE
touch linux unix ccna ccnp

Open the the config file and make an entry in it as below

vi /etc/exports

/NFSSHARE  10.10.10.21(rw,sync)
OR
/NFSSHARE  10.10.10.0/24(rw,sync)

To verify the eport configuration file

exportfs -avr
Client Side Configuration :
yum install nfs-utils 

To know the list of shares available on NFS Server

showmount -e  NFS Server IP
as below
showmount -e  10.10.10.23

To mount nfsshare on your local partition use below command

mkdir -p /media/NFSLOCAL
mount -t nfs  10.10.10.23:/NFSSHARE  /media/NFSLOCAL 

To check nfsshare has mounted perfect or not use below command

df -Th

With mount command we have mounted nfsshare as temporarily to mount same as permanently keep the below in /etc/fstab

vi /etc/fstab
10.10.10.23:/NFSSHARE /media/NFSLOCAL  nfs defaults  0 0 
:wq

To verify mount

mount -a

Limitations of NFS:

  • We can only exports the directories which are started with “/”.
  • We can exports the files only to the homogeneous environment.
  • Only local file systems can be exported
  • It uses only in private network

/var/lib/nfs/rmtab: This file contains exported list which are mounted by list

/var/lib/nfs/etab: This file contains currently exported file system information.

Leave a Reply

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