How To Set Up an NFS Mount on CentOS 7
Setup
Master - SERVER: 192.168.0.81
Client: 192.168.0.119
Setting Up the NFS Server - 192.168.0.81
Step One—Download the Required Software
1 . yum install nfs-utils , rpcbind
Subsequently, run several startup scripts for the NFS server:
systemctl enable nfs-server.service
systemctl start nfs-server.service
systemctl start rpcbind.service
Step Two—Export the Shared Directory
We need to export the directory:
vi /etc/exports
Add the following lines to the bottom of the file, sharing the directory with the client:
/home/testdir 192.168.0.119(rw,sync,no_root_squash,no_subtree_check)
These settings accomplish several tasks:
- rw: This option allows the client server to both read and write within the shared directory
- sync: Sync confirms requests to the shared directory only once the changes have been committed.
- no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger filesystem, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
- no_root_squash: This phrase allows root to connect to the designated directory
Once you have entered in the settings for each directory, run the following command to export them:
exportfs -a
Setting Up the NFS Client - 192.168.0.119
Step One—Download the Required Software
yum install nfs-utils
Step Two—Mount the Directories
mkdir -p /mnt/nfs/home/testdir
Then go ahead and mount it
mount 192.168.0.81:/home/testdir /mnt/nfs/home/testdir
You can use the df -h command to check that the directory has been mounted. You will see it last on the list.
df -h
You can ensure that the mount is always active by adding the directory to the fstab file on the client. This will ensure that the mount starts up after the server reboots.
vi /etc/fstab
192.168.0.81:/home/testdir /mnt/nfs/home/testdir nfs auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0
Removing NFS Mount
if you decide to remove a directory, you can unmount it using the umount command:
cd
sudo umount /directory name
sudo umount /directory name
You can see that the mounts were removed by then looking at the filesystem again.
df -h
Comments
Post a Comment