User Tools

Site Tools


archive:centos_install_nfs

Setting up NFS on CentOS

On The NFS Server

yum install nfs-utils

Note: Centos 7.2 and earlier Needs the following as well

yum install nfs-utils-lib

Enable services at Boot

systemctl enable rpcbind
systemctl enable nfs-server
systemctl enable nfs-lock
systemctl enable nfs-idmap

Startup services

systemctl start rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap

Create a shared directory

mkdir /nfsshare
chmod 777 /nfsshare

Create A Lst Of Exported NFS Shares (In this guide we only create 1 share)

vi /etc/exports

In That File Add The Following: (Replace the allowed ip address and or range with what you need)

/nfsshare ip_allowed(rw,sync,no_root_squash,no_all_squash)

Note There is no space between the ip_allowed and the rest of the line.

Also if you want to allow multiple hosts you need to put them into one line like this.

/nfsshare ip_allowed(yadda,yadda,yadda) ip_allowed(yadda,yadda,yadda)

The Above Explained:

192.x.x.x Allowed Ip Address
rw – Writable permission to shared folder
sync – Synchronize shared directory
no_root_squash – Enable root privilege
no_all_squash - Enable user's authority

Next Export The Shared Directories Like This:

exportfs -r

Additional exportfs commands

exportfs -v : Displays a list of shares files and export options on a server
exportfs -a : Exports all directories listed in /etc/exports
exportfs -u : Unexport one or more directories
exportfs -r : Reexport all directories after modifying /etc/exports

Restart the nfs service

systemctl restart nfs-server

Check If We Can See The Share

showmount -e nfsshare_ip

On The Client

yum install nfs-utils nfs-utils-lib

Create a local mountpoint and mount the share

mkdir /mnt/backup
mount -t nfs 10.0.235.6:/miscbackup /mnt/backup

Verify The Share Is Mounted

mount | grep nfs
df -hT

Permanent mount

vi /etc/fstab

Add the following

10.0.235.6:/miscbackup    /mnt/backup   nfs defaults 0 0

Firewall

If You Are Running A Firewall Remember To Allow NFS Like This

firewall-cmd --permanent --zone public --add-service mountd
firewall-cmd --permanent --zone public --add-service rpc-bind
firewall-cmd --permanent --zone public --add-service nfs
firewall-cmd --reload
archive/centos_install_nfs.txt · Last modified: 24/11/2023 12:40 by Allan