NFS, is abbreviation of Network File System, is a server-client protocol used for sharing files between linux/unix to unix/linux systems. with  NFS enabled you can  mount a remote share locally. You can then  access  the data  , read   and writes  things  and thats depend  on the setup. please nore  that  NFS   share  in one the  objectifs of  RHCE  exam . and  this  tutorials  will help  you to understand  how things  works

This tutorial should work for all Redhat based  sustems  like Centos  /  Oralce Linux / and  Scientific Linux and  will explain  how to install NFS  Server and  NFS  Client

In my articles  am using  2 Centos7   servers

NFS Server Hostname: nfs-server
NFS Server IP Address: 192.168.189.128/24
NFS Client Hostname: nfs-client
NFS Client IP Address: 192.168.189.129/24

NFS Server Side Configuration

Install NFS packages in your Server system with  the following command:

yum install nfs-utils

Enable and start NFS services:

Now,  we will try  to share some directories

Create a folder named ‘/var/nfs_share’ in server and lets the client users to read and write files in that directory.

Export shared directory on NFS Server:

Edit file /etc/exports,

vi /etc/exports
Add the following line:

Explaination 

/var/nfs_share – shared directory
192.168.189.0/24 – IP address range of clients
rw – Writable permission to shared folder
sync – Synchronize shared directory
no_root_squash – Enable root privilege
no_all_squash – Enable user’s authority

Allow  NFS  ports  on Firewall 

On server side If you don’t know which ports to allow through firewall, run the following command:

rpcinfo -p
Sample output:
nfs-rpc

You should allow the above ports.

To do that, go to the NFS server, and run the following commands:

Or

Restart firewalld service to take effect the changes:

Restart the NFS service:

NFS Client Side Configuration

Install NFS packages in your client system by using the following command:

yum install nfs-utils nfs-utils-lib
Enable and start NFS services:

Create  a local founder  and  mount   NFS   share   on it

Show what is shared in remote host 

Mount the share from server to client as shown below

results :

Verify the share from the server is mounted or not using ‘mount’ command.

mount
Sample output:

Auto mount NFS Shares

To mount the shares automatically instead of mounting them manually on every reboot, add the following lines shown in bold in the ‘/etc/fstab’ file of your client system.

vi /etc/fstab

fstab

Reboot  and Enjoy

Thats it. Now NFS server is ready to use.

SHARE
Linux Engineer, born in Morocco, living in Amsterdam. with large knowledge of TUX and opensource. am Working with Linux from very long time , i have created this blog to serve people. please join us

LEAVE A REPLY

Please enter your comment!
Please enter your name here