Watch all our Tutorials and Training Videos for Free on our Youtube Channel, Get Online Web Tools for Free on

Search Suggest

How to Install and Configure NFS Server on Linux Easily

nfs configuration on linux, configure nfs on linux, install nfs on linux, install nfs linux, linux nfs server configuration, install nfs server centos
This post will show you Install and Configure NFS Server on Linux Easily.

Installing and Configuring NFS Server on RHEL7

The main purpose of this article is to explain the below things,

  1. What is NFS (Network File System)?
  2. What is required?
  3. How to Install NFS?
  4. How to Configure NFS Server?
  5. How to mount NFS share on client?

What is NFS?

A Network File System (NFS) allows remote hosts to mount file systems over a network and interact with those file systems as though they are mounted locally. This enables system administrators to consolidate resources onto centralized servers on the network.

What is Required?

nfs-utils and rpcbind packages at the server end.

How to Install NFS Server on Linux?

Install the required packages using YUM as follows, if YUM not configured please visit the link How to Configure Local YUM Repo Server in Linux
[root@server1 ~]# yum -y install nfs-utils rpcbind

Installing and Configuring NFS Server on Linux

Before configuring the NFS Server, start and enable the rpcbind and nfs services.
[root@server1 ~]# systemctl start rpcbind
[root@server1 ~]# systemctl start nfs

There are two ways to configure an NFS server:

1. Manually editing the NFS configuration file, that is, /etc/exports, and
2. through the command line, that is, by using the command exportfs.

Editing /etc/exports Configuration File:

The /etc/exports file controls which file systems are exported to remote hosts and specifies options. It follows the following syntax rules:

  1. Blank lines are ignored.

  2. To add a comment, start a line with the hash mark (#).

  3. You can wrap long lines with a backslash ().

  4. Each exported file system should be on its own individual line.

  5. Any lists of authorized hosts placed after an exported file system must be separated by space characters.

  6. Options for each of the hosts must be placed in parentheses directly after the host identifier, without any spaces separating the host and the first parenthesis.

Each entry for an exported file system has the following structure:
export host(options)

The structure uses the following variables:

export - The directory being exported
host - The host or network to which the export is being shared
options - The options to be used for host

It is possible to specify multiple hosts, along with specific options for each host. To do so, list them on the same line as a space-delimited list, with each hostname followed by its respective options (in parentheses), as in:
export host1(options1) host2(options2) host3(options3)

In our scenario we define two hosts and one share folder /mydata which we use to export to the client:

NFS Server, IP
NFS Client, IP

At NFS Server End Configuration

Edit the configuration file,
[root@server1 ~]# vi /etc/exports

Add the below list of folders as follows to be exported and file looks like below,
[root@server1 ~]# cat /etc/exports
/mydata *(rw)

Issue the below command  to reread to Re-export all NFS directories:
[root@server1 ~]# exportfs -ra

Check the configuration as follows to ensure the newly added settings:
[root@server1 ~]# showmount -e
Export list for
/mydata *
[root@server1 ~]#

Server end configuration is done.

At NFS Client End Configuration

Login into the client and verify the nfs shared volumes using the below command.
[root@client1 ~]# showmount -e
Export list for
/mydata *
[root@client1 ~]#

Mount the NFS volume:
[root@client1 ~]# mount /mnt/
[root@server1 ~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root          7.5G  5.0G  2.6G  67% /
devtmpfs                       108M     0  108M   0% /dev
tmpfs                          118M     0  118M   0% /dev/shm
tmpfs                          118M  8.6M  109M   8% /run
tmpfs                          118M     0  118M   0% /sys/fs/cgroup
/dev/sda1                      497M  119M  379M  24% /boot
/dev/mapper/VolGroup00-lvol00  4.8G   20M  4.6G   1% /mydata            4.8G   20M  4.6G   1% /mnt

That's it, we are done with NFS Server configuration at both server and client end.

Related Content on Linux might be useful to you to improve your Linux Skills.

Keep practicing and have fun. Leave your comments if any.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.