How to setup NFS Server and Client on CentOS 7

How to setup NFS Server and Client on CentOS 7

Server side:

1. Install NFS Utils.
$ yum -y install nfs-utils

2. Enable and start the NFS service
$ systemctl enable nfs-server.service
$ service nfs-server status

3. Create a directory for the share. You may use existing directory for share.
The directory’s permission is important. If users don’t have any permission on the directory, NFS client also don’t have permission there.
Therefore, you may set the correct permission by “chmod”.

For read and executable,
$ chmod 755 <share path>

For read, write and executable,
$ chmod 777 <share path>

You may also change the ownership of the directory by “chown”.

4. Modify “/etc/exports” to export the share. Be careful of the space. This file is sensitive of space therefore be accurate.

I’m sharing “/uge” directory to internal network “”. Therefore, modified /etc/exports as following.
[root@chanel ~]# cat /etc/exports

no_root_squash option allow the share path(/uge) to be accessibile as root.

5. Run following to apply the changes.
$ exportfs -a


Client side:

1. Install NFS Utils.
$ yum -y install nfs-utils

2. Create a directory to mount the share. I created “/uge” in the client which is same as server’s path.

3. Mount the share of the server as following

$ mount <Server’s IPv4 addr>:<share path> <mount path>
ex) $ mount /uge

You may use hostname instead of server’s IP address.
4. Check if the share is successfully mounted.
$ ls -al <mount path>

5. In order to keep the mount permanently although system reboots, modify “/etc/fstab”.
My /etc/fstab is as following.

[root@lv ~]# cat /etc/fstab

# /etc/fstab
# Created by anaconda on Wed Nov 30 09:46:22 2016
# Accessible filesystems, by reference, are maintained under ‘/dev/disk’
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
/dev/mapper/centos-root / xfs defaults 0 0
UUID=9f994ee2-ebe8-4dc5-8ea5-9002bbc5b353 /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0 /uge nfs rw,sync


As you see, the pattern is like this.
<Server’s IPv4 addr>:<share path> <mount path> nfs rw,sync


There are lots of option of the mount. Generally try the rw,sync and modify as you wish.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s