Skip to main content

In this guide we will cover how to set up NFS on our file system in order to mount a directory over our network. The NFS protocol was designed in 1984 by Sun Microsystems and like any other protocol, it defines the rules and behaviors that two computers must follow in order to successfully communicate with each other. This guide will walk through the installation and setup of NFS on your file system.

The NFS installation, regardless of distribution, can be summed up in four steps:

1. Install the NFS package.

2. Create or choose the directory to be shared.

3. Edit the /etc/exports file.

4. Start the NFS service.

This guide is aimed at beginners, who have no previous experience setting up NFS. In part two and three of this guide, we will cover setting up NFS using Kerberos for authentication, and setting up NFS servers with an failover option.

Getting Started

Note: This guide is designed to introduce you to NFS. In order to make the introduction as simple as possible, this guide takes liberties in not discussing topics which will be covered in part two of this guide where we will cover authentication among other topics. The following set up is not recommended for a production environment.


  • A Debian or Arch base distribution with an active Internet connection.
  • Ability to open and use a Linux terminal.
  • Your server must have a static IP.

Server Side Installation

Before we begin the installation, let’s take a quick moment to jot down our server’s IP address. We can do this with ifconfig

$ Ifconfig 
lo Link encap:Local Loopback
inet addr: Mask:
inet6 addr: ::1/128 Scope:Host
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 b) TX bytes:480 (480.0 b)

enp0S3 Link encap:Ethernet HWaddr 00:1C:C0:AE:B5:E6
inet addr: Bcast: Mask:
inet6 addr: fe80::21c:c0ff:feae:b5e6/64 Scope:Link
RX packets:41620 errors:0 dropped:0 overruns:0 frame:0
TX packets:40231 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:21601203 (20.6 MiB) TX bytes:6145876 (5.8 MiB)

Your output will vary from mine. ifconfig gives you a list of the network interfaces on your system. The first interface you will come across is lo otherwise known as the loopback interface, followed by however many network interfaces you have installed on your system.

Your local IP address will follow after inet as shown above. We need the server’s IP address in order to mount our directory from the client. This is why it is important to have a static IP set up on your server. If you don’t, once your server changes its local IP, your configuration on the client side will break.

Now that we have the local IP of our server, we are ready to continue.


With your package manager of choice, install the nfs-server package.

sudo apt install  nfs-server 

If you’re on an Arch base system you can use the pacman or yaourt package manager in order to install the NFS package. In the Arch repositories however, the NFS package is named nfs-utils.

sudo pacman -S nfs-utils

After installing NFS, we begin by creating the directory that we would like to share.

sudo mkdir -p /srv/nfs/home

In this instance, we are creating both an nfs and a home subdirectory by passing mkdir -p. Keep in mind that you have free reign when it comes to naming your directory and its location.

In order for all users to have access to our shared directory, and simplifying the authentication process. We need to change the permissions to read, write, and execute recursively on our directory.

sudo chmod 777 -R /srv/nfs/home

Once the directory is created and we have given it proper permissions, we are ready to continue our set up by editing the exports file in our /etc directory. The /etc/exports file controls which directories are allowed to be mounted on remote systems. So in order to share our newly created directory with our clients, we are going to add it to our exports file.

sudo vim /etc/exports

Let’s start by adding the name of the directory we created to the end of our /etc/exports file.


Followed by the IP of the clients that are going to be allowed to access the shared directory. I’m on a class C network therefore I’m using the shorthand /24 to allow all local IPs to connect to my shared directory. However, you can add access to the directory by giving the exports file specific IPs such as /srv/nfs/home


Finally we add our options.

/srv/nfs/home,sync, no_root_squash)

Save and close the file.

Make sure everything is written exactly as you see it. Typos in this configuration will cause issues when you attempt to start the nfs-server.

After finishing setting up our server configuration file, we are ready to start the nfs-server.

On a Debian base system

sudo systemctl start nfs-server

On Arch base systems you can use

sudo systemctl start nfs-utils

Let’s check the status of the server, to ensure that it now shows as active. Use nfs-server for Debian based distributions or nfs-utils on Arch base distributions.

sudo systemctl status nfs-server

Also check that the rpcbind service is up and running.

sudo systemctl status rpcbind

If everything is up and running, you have completed the NFS server side set up.

Client side setup


We start by installing the NFS package on the client machine. If you are using a Debian based distribution, use the following command.

sudo apt install nfs-common

On an Arch base distribution you can use

sudo pacman –S nfs-utils 


We start by creating the directory in which we are going to mount our remote directory.

mkdir  /mnt/sharedir

After we create our directory, we are ready to mount the remote directory we created on our server by using the mount command, followed by our server’s IP (remember to use the IP on your server) followed by a colon, and the directory we created on our server. We then give the mount command the local directory in which we will mount our remote directory.

sudo mount  /mnt/sharedir

Your NFS directory should now be mounted and ready to use.

Let’s do a quick test.

On your client

cd /mnt/sharedir

mkdir itworks 

Then on your server

cd /srv/nfs/home 


and you should see the itworks directory that we just created. We can permanently mount the directory on our system, by editing the /etc/fstab file. The format for adding our directory is as follows: /mnt/sharedir auto,nofail 0 0 

The nofail option allows the operating system to continue its normal boot up process should the remote directory not be available to mount at the moment.

Sources / Resources

  • Linux Linux Foundation Certified System Administrator (LFCSA v2.16) on Linux Academy.
Comments are disabled for this guide.