Skip to main content

Set Up an NFS Mount on CentOS 7

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
You can see that the mounts were removed by then looking at the filesystem again.
df -h









Comments

Popular posts from this blog

Install IBM Java8 on centos 7( problem - JRE libraries are missing or not compatible.... Exiting.... )

We have IBM CPU with centos7 as operating system. We need to install JAVA 8 provided by IBM, below are some steps which are used for this installation- 1. Download IBM JRE(ibm-java-ppc64-jre-8.0-3.12.bin) from IBM official site. http://www.ibm.com/developerworks/java/jdk/java8/  a.) Select your required JRE such as, we need Linux 64-bit IBM POWER, and click   on download now, fill login details or guest user and download .bin file using download director or http. Http will be more convenient to download. 2. Change executable permissions to ibm-java-ppc64-jre-8.0-3.12.bin file. 3. Execute file using bash  ./ibm-java-ppc64-sdk-8.0-3.12.bin 4. You will get installation window if everything gonna fine. 5. But if you got some error like - JRE libraries are missing or not compatible.... Exiting.... Cause for problem is that LAX(install anywhere) unable to find correct JVM on your system. So, we have to provide correct correct java to LAX 6. To see full logs, run comma