How to Set Up and Configure NFS Client and Server on Arch Linux
NFS (Network File System) is a protocol that allows you to share files over a network. NFS is widely used in Linux environments, especially for sharing data between servers and clients. In this article, we will show you how to install and configure the NFS server on Arch Linux and how to connect to it from another Arch Linux machine.
Contents:
- How to Install NFS Server/Client on Arch Linux
- Setup the NFS Server
- Setup the NFS Client
- Testing the NFS Server/Client
- Make the NFS Server Auto Start at BOOT
- Conclusion
How to Install NFS Server/Client on Arch Linux
To install the NFS server and client, you can use the Pacman package manager. Once NFS is installed, you can set up the server-client communication using it. Before we begin, we need to have two Arch Linux machines: NFS Server and NFS Client.
We have two machines with a GNOME desktop environment, but this tutorial will also work with other desktop environments or window managers. Make sure your both machines have a working network connection and can ping each other by hostname or IP address.
Setup the NFS Server
To set up the NFS server, first synchronize your system clock with the NTP service. Once done, you can proceed with the NFS installation using the Pacman command. After that, we will create two directories to mount them on the Client. After creating the directories, you have to export the NFS shares file and enable the NFS server using the systemctl command.
Follow these steps to get the NFS server running on your Arch machine.
Step 1: Synchronize the System Clock with the NTP Service
Start by synchronizing the system clock of both machines. This step is important for NFS security. To do this, we can use the timedatectl command to check the NTP service and the system clock.
timedatectl
From the output, you can see the NTP service is already enabled. If the NTP service is not active, you can enable it by typing:
sudo timedatectl set-ntp true
Then, you can sync the hardware clock with the system clock by typing:
sudo hwclock --systohc
After that, you can verify that the system clock and the NTP service are active by typing:
timedatectl
Step 2: Installing NFS Server on Arch Linux
Now that your machine is ready, you can proceed to install the NFS server on Arch Linux. To install the NFS server, run the Pacman with the -S option:
sudo pacman -S nfs-utils
This will install the nfs-utils package, which contains the necessary tools and services for NFS. After installation, now create and export the NFS shares directory.
Step 3: Creating and Exporting NFS Shares on Arch Linux
Now, you need to create the directories that you want to share over NFS and set the appropriate permissions and ownership. I will create two directories: one under my home directory called server, and another under the /srv directory called nfs.
To create the first directory, you can use the mkdir command:
mkdir Documents/server

sudo mkdir /srv/nfs
Step 4: Editing the NFS Exports File
Now that you have created shareable directories, you need to export them to the network by editing the /etc/exports file. This file contains the list of directories that are shared over NFS and the options that control their access. To edit the file, use any text editor.
For example, you can use Nano to edit this file:
sudo nano /etc/exports
This file contains some examples of how to define the shares. Now go to the last line and create a new one for each directory that you want to share.
/path/to/share *(rw,sync)
Make sure you replace /path/to/share with the actual location of your shared directory on your computer.
In our case, we are going to add the /srv/nfs and /server directories:
/srv/nfs *(rw,sync) /home/linux/Documents/server *(rw,sync)
You can find many examples on the ArchWiki on how to restrict access to the share by IP. But if you want to make it accessible to everyone on the same network, you have to use the asterisk (*) and then specify the options: rw,sync. This means the data will be synced immediately. It uses more resources than the async method, but it’s fine for my small server. You can modify these options as per your permissions need.
In the second line, I have defined another share under my home directory. The options are the same: read, write, and sync. That’s it for this file.
Step 5: Reload and Export the NFS Exports
After saving the changes, you need to export and reload the NFS export configuration file. Exporting NFS-shared files will make them available to all hosts on the same network. This can be useful for consolidating resources, sharing data, or accessing files from different locations.
To export the NFS file shares, run this command:
sudo exportfs -arv
After saving and closing the file, we need to reload the nfs-server service to apply the changes by typing:
sudo systemctl reload nfs-server
Step 6: Enable the NFS Service
Now start and enable the NFS systemd service by running this command:
sudo systemctl enable --now nfs-server
This will make the nfs-server service run at boot and start immediately.
To check the status of the server, run this command:
systemctl status nfs-server
As you can see, the NFS server is up and running.
Step 7: Configure Firewall for firewalld
If you have a firewall on your server, like firewalld, then you need to open three services: nfs, mountd, and rpc-bind. This allows you to connect with the NFS server from the client. Else, an error will appear.
Open firewall ports for NFS services by running these commands:
sudo firewall-cmd --add-service=nfs --permanent sudo firewall-cmd --add-service=mountd --permanent sudo firewall-cmd --add-service=rpc-bind --permanent
Reload the firewall:
sudo firewall-cmd --reloads
Step 8: Check the NFS Server IP Address
Check server IP, it will be needed for Client connection:
ip a
Now the server is ready. Let’s switch to the client.
Setup the NFS Client
After setting up the NFS server, you need to configure the NFS client to access the shared directories. The NFS client requires the installation of the nfs-utils package and a mount point for each shared directory.
Let’s begin with the NFS Client configuration.
Step 1: Synchronize the System Clock with the NTP Service
Like the NFS server, the first step in setting up the NFS client is to synchronize the system clock with the network time protocol (NTP) service. You need to do this because the NFS relies on timestamps to verify the validity of requests and responses.
First, check the NTP service by running the below command:
timedatectl
You can see the NTP service is disabled. To enable it, run this command:
sudo timedatectl set-ntp true
This command will enable the NTP service and sync the system clock with an online server.
Now reload the hardware clock using this command:
sudo hwclock --systohc
This command writes the system time to the hardware clock. It is used to keep time when the system is off.
Now check if the NTP service is now active or not:
timedatectl
Step 2: Installing the NFS Client
To connect to the NFS server from the Arch Linux machine that will act as the client. You will need to install the nfs-utils package on the client machine as well:
sudo pacman -S nfs-utils
Step 3: Creating the Mount Point
Next, you have to create the directories where the NFS shares will be mounted on the client machine. A mount point is a location in the local file system that acts as a gateway to access the remote file system.
You can follow this syntax to list the available NFS shares on the remote server:
showmount -e <server IP here>
For example, to show the shares on the server with IP 192.168.00.00, run this command:
showmount -e 192.168.00.00
Then, we need to create the mount points where we want to access the NFS shares.
mkdir ~/mountpoint
For example, you can run the below command to create two subdirectories under the Documents directory, one for each share:
mkdir Documents/{server,nfs}
Now change the current working directory to Documents. Next, run the ls command to list and confirm the two newly created subdirectories for each share:
cd Documents/ ls
Step 4: Mounting the Shared Directory
Next, you need to mount the NFS shares to the mount points on the client machine. This allows the client to access files on the remote server.
First change the current working directory to the user’s home directory:
cd
To mount the NFS share with the client mount point, you can use the mount command. For this, you can follow the below syntax:
sudo mount -t nfs <servername or ip>:/path/to/share ~/mountpoint
For example, to mount the NFS /home/linux/Documents/server directory from the server with the IP address 192.168.00.00 to the Documents/server directory on the client, run:
sudo mount -t nfs 192.168.00.00:/home/linux/Documents/server Documents/server
Similarly, to mount the /srv/nfs directory from the same server to the Documents/nfs directory on the client, run this command:
sudo mount -t nfs 192.168.00.00:/srv/nfs Documents/nfs
Step 5: Verify the Mounted Directory
Finally, verify if the NFS shares are mounted correctly on the client machine or not. For this, you can run the mount command:
mount
This displays information about all the mounted file systems on the system, including the NFS shares.
From the output, you can see the Client is mounted with the NFS shares.
Testing the Server and Client Connection
Now, you can access the NFS shares from the client machine and read or write files and directories. To test the connection between both Server and Client, you can create a test file or type any text inside the file.
Creating a Test File on the Client Side
Now open the terminal on the Client side and head over to the Documents/server/ directory. First list the item to check if there is anything there:
cd Documents/server/ ls
Now create a text file using the touch command:
touch file.txt
Again, list the items to confirm the file is created:
ls
Checking the Same Files on the Server Side
Now open the terminal on the Server computer and navigate to the server subdirectory. After that, list the items to confirm if the same file is created or not:
cd Documents/server/ ls
As you can see, the text file is here.
So the Client Server connection is working and up.
So far, you have learned how to create and edit files inside the server directory using NFS. However, if you create files inside the nfs directory, you will encounter permission issues.
First, navigate to nfs directory and list all items:
cd nfs/ ls
Now create a file using the touch command:
touch file.txt
This time you will see the permission denied error.
The above error shows that you do not have permission to create files in the nfs folder on the client. To understand why this is happening, go back to the Server and check the permissions of the server and the nfs folders.
For this, run the ls -l command to list folder contents in the long format. This option shows the permissions, the owner, the group, and other information:
cd Documents/ ls -l
Here, you can see that the server folder belongs to two users: the user and the group user. It means that both the owner of the folder and group members can read, write, and execute the folder.
On the other hand, the nfs folder belongs to the root user. This means that this folder is restricted to only the root user. The others can only read and execute the folder.
Chmod on the Server Side
To fix this issue, you need to change the owner and the group of the nfs folder to match the user and the group of the server folder.
To do this, use the chmod command on the server to change the owner and the group of the nfs folder.
sudo chmod <mod-exmple-777> /etc/exports.d/shares
For example, To give permission for /srv/nfs folder, run this command:
sudo chmod -R 777 /srv/nfs
To verify that the permissions are updated, run the ls -l command again:
ls -l
Now go back to the client and try again to create the text files in the nfs directory.
cd nfs/ ls
touch file.txt
You can see everything is working fine.
Now open the same file on the server side.
That’s it, NFS Server and connect a Client to it.
Make the NFS Server Auto Start at BOOT
For now, we have set up the NFS server, but the issue is whenever the Client computer gets shut down or rebooted, this connection will be disrupted. To maintain the Server Client connection, you have to edit the /etc/fstab file. The /etc/fstab file contains information about the file systems that are mounted on the system at boot time or manually.
Open the Client terminal and run the below command to edit the fstab file:
sudo nano /etc/fstab
Now add the following line at the end of the file:
192.168.00.00:/home/linux/Documents/server /home/linux/Documents/server nfs rw,sync,_netdev 0 0
This line adds an entry to the /etc/fstab file that tells the system to mount the remote directory /home/linux/Documents/server from the NFS server with the IP address 192.168.00.00 to the local directory /home/linux/Documents/server using the NFS protocol. The options rw, sync, and _netdev specify that the mount point is read-write, synchronized, and network-dependent.
Similarly, add the following line to make the Client /srv/nfs directory auto-connect with the NFS Server computer:
192.168.00.00:/srv/nfs /home/linux/Documents/nfs nfs rw,sync,_netdev 0 0
This line adds another entry to the /etc/fstab file that tells the system to mount the remote directory /srv/nfs from the same NFS server to the local directory /home/linux/Documents/nfs using the same options as the previous line.
After that, reboot the Client’s computer to test if the NFS Client auto-connects. Ensure the NFS Server computer is up and running:
reboot
You can also run the mount command to check if the Client is still mounted to the same IP address:
mount
From output, you can see the Client computer is successfully mounted even after rebooting the system.
Now you can create and share new files and folders using the two mounted directories.
Conclusion
NFS is a network file system that allows file sharing in a network. We have installed and configured the nfs-utils package on both the Server and the Client machines. We have also created and mounted the NFS shares using the /etc/exports and /etc/fstab files. After that, we tested the NFS functionality by creating and accessing files on the shared directories.

































