Setup NFS Server on RHEL

If you need to share files between multiple servers, the easiest way is to setup a nfs-server.

Install Packages

First you need to install the necessary packages on the server, you want to host the share on.

[tux@server]$ sudo dnf install nfs-utils

Configure Exports

The next step is to define which folders will be available for which client. This is done in the configuration file /etc/exports.

The structure of this file is

local-directory client(options)

The fields are separated by spaces, so do not use tab or multiple spaces.

In this example I want to share the folder /mnt/public and only with serverb.lab.

[tux@server]$ sudo vim /etc/exports
/mnt/public serverb.lab(rw)

This allows serverb.lab to read and write to the share. If you want to make the access public, you can use an * instead of the servername or ip.

If you make any changes, once the nfs-service is running, you need to reload the configuration.

[tux@server] sudo systemctl reload nfs-server

Start the NFS Server

Now we need to start the services.

[tux@server]$ sudo systemctl enable --now nfs-server
[tux@server]$ sudo systemctl enable --now rpcbind


If you are using a firewall, you need to open the ports.

[tux@server]$ sudo firewall-cmd --add-service=nfs --add-service=rpc-bind --add-service=mountd
[tux@server]$ sudo firewall-cmd --runtime-to-permanent

Testing the Export

If you want to test the export on your client, you can use showmount.

[tux@serverb]$ showmount -e <nfs-server>

This will list all of the available NFS shares on the server.

profile picture of the author

Jannik Rehkemper

I'm an professional Linux Administrator and Hobby Programmer. My training as an IT-Professional started in 2019 and ended in 2022. Since 2023 I'm working as an Linux Administrator.