Setup NFS Server and Client on RHEL7/Centos7

install Nfs Server on jagolinux

NFS is usually used by the Linux or Unix operating system to be able to share files. NFS Unlike Samba, samba is used to share files from Linux / Unix to Windows while NFS (Network file system) is used to share linux or unix files. In this article the admin will show you how to set up the NFS server and NFS Client.

nfs-server-client on rhel7/centos7

In the first step, type the following command on your NFS server.

yum install nfs-utils nfs-utils-libs

enable nfs service when the server is restarted the service will automatically start, please type the command.

 systemctl enable nfs
systemctl enable rpcbind
systemctl enable nfs-lock
systemctl start nfs
systemctl start rpcbind

the next step, enter the directory path that you will share with /etc/exports like this

/home/jagolinux/nfs-shared 192.168.1.2/24(rw,sync,no_root_squash,no_all_squash
/home/rhel7 192.168.1.3/24(rw,sync,no_root_squash,no_all_squash)

Noted:

/home/jagolinux and /home/rhel7 – directory you will be shared.

192.168.1.2/24 and 192.168.1.3/24 – Ip address nfs client.

rw – read and Write Permission for shared directory.

sync – Syncronize shared directory.

no_root_squash – enable root privilege

no_all_squash – enable users authority

if you have finished adding the directory path to /etc/exports then restart your nfs service.

 systemctl restart nfs 

and then you can check status of NFS service with command

 systemctl status nfs

to export the directory that you shared, type the following command

exportfs -r

 

and check your shared with command on nfs server.

showmount -e 

 

on the NFS client side you follow the steps below

install NFS package like NFS Server,

yum install nfs-utils nfs-utils-lib 

 

and than start and enable NFS client service

 systemctl enable nfs
systemctl enable rpcbind
systemctl enable nfs-lock
systemctl start nfs
systemctl start rpcbind

create mount point to mount shared directory /home/jagolinux/nfs-shared, which we have previously made on the server.

mkdir /mnt/mount-nfs 

and mount NFS shared directory to mount point.

  mount -t nfs 192.168.1.1:/home/jagolinux/nfs-shared /mnt/mount-nfs

note:

192.168.1.1 is NFS Server,

 

or you can edit /etc/fstab for automatic mount after restart and add to the bottom row.

 192.168.1.1:/home/jagolinux/nfs-shared /mnt/mount-nfs nfs defaults     0 0  

on client please type command for show nfs server shared

 showmount -e 192.168.1.1 

note:

192.168.1.1 – NFS Server

we hope this article can help you about how to install NFS Server on rhel7 or Centos7.

 

 

 

 

Facebook Comments