Jul 3, 2023 5 min read

How to Install and Configure an NFS Server on Ubuntu 22.04

Install an NFS Server on Ubuntu 22.04 with our step-by-step tutorial. It enables file sharing and data access between computers on a network.

Install and Configure an NFS Server on Ubuntu 22.04
Table of Contents

Choose a different version or distribution

Introduction

Before we begin talking about how to install and configure an NFS Server on Ubuntu 22.04, let's briefly understand – What is NFS Server?

NFS Server, or Network File System Server, is a powerful technology that enables file sharing and data access between computers on a network. It allows multiple clients to access files stored on a central server as if they were located on their own local machines.

NFS Server simplifies file management, improves collaboration, and enhances data security. By providing a standardized protocol for file sharing, it enables seamless interoperability across different operating systems and devices. With NFS Server, organizations can efficiently manage their data, boost productivity, and foster collaboration among team members.

In this tutorial, you will install and configure the NFS server on Ubuntu 22.04. We will also address a few FAQs on how to install and configure NFS Server on Ubuntu 22.04.

Advantages of NFS Server

  1. Seamless File Sharing: NFS Server enables effortless sharing of files between multiple computers on a network, enhancing collaboration and productivity.
  2. Centralized Storage: It allows for centralized storage of files, making it easier to manage and backup data.
  3. Cross-Platform Compatibility: NFS Server supports multiple operating systems, enabling seamless file sharing across diverse platforms.
  4. Improved Performance: It offers efficient data access and retrieval, optimizing file transfer speeds and reducing network latency.
  5. Enhanced Security: NFS Server provides robust security features, including access control and authentication mechanisms, ensuring data privacy and integrity.

InstalI NFS server on Ubuntu 22.04

Follow the directions provided in order to install the NFS server on Ubuntu 22.04.

Step 1: Update system packages

Then, use the supplied command to update the system packages by pressing CTRL+ALT+T:

sudo apt update

Every package has been updated:

Step 2: Install NFS server

To install an NFS server, carry out the following command in the Ubuntu 22.04 terminal:

sudo apt install nfs-kernel-server

The shown output shows that the Ubuntu 22.04 "linuxuser" system has successfully installed the NFS server:

Let's proceed to configuring the NFS server that has been installed.

Configuring NFS server on Ubuntu 22.04

Follow the directions provided to configure the NFS server on Ubuntu 22.04.

Step 1: Create shared NFS directory

First, a directory called "nfs_share" will be created and shared by all client systems. Write the following command to do so:

sudo mkdir -p /mnt/nfs_share

Step 2: Set directory permissions

Next, modify the "nfs_share" directory's permissions so that all client machines may readily access it:

sudo chown -R nobody:nogroup /mnt/nfs_share/

Step 3: Set file permissions

Set the necessary file permissions. In our scenario, the "nfs_share" directory files have been given the read, write, and execute permissions:

sudo chmod 777 /mnt/nfs_share/

Step 4: Grant NFS access

We will provide the client system permission to access the NFS server in this step. Open /etc/exports in the nano editor to accomplish this:

sudo nano /etc/exports

You can now choose whether to provide access to a single client, a group of clients, or the entire subnet. For instance, we'll allow 10.0.2.15/24 as a whole subnet to access the NFS share:

/mnt/nfs_share 10.0.2.15/24(rw,sync,no_subtree_check)

Use CTRL+O to save the file after adding the necessary line, then return to the Ubuntu 22.04 terminal.

Step 5: Exporting NFS directory

Make use of the command given to export the NFS shared directory:

sudo exportfs -a

Step 6: Restart NFS server

Use the following command on your Ubuntu 22.04 machine to restart the NFS server:

sudo systemctl restart nfs-kernel-server

Step 7: Grant Firewall access

Then, use the ufw command to allow the Firewall access to the client system:

sudo ufw allow from 10.0.2.15/24 to any port nfs

Step 8: Enable Firewall

Use the ufw command and the enable option to turn on the firewall:

sudo ufw enable

Step 9: Check Firewall status

Next, make sure the firewall is set up to permit access over port 2049:

sudo ufw status

To test the NFS sharing point, we will now proceed to the "ubuntuuser" system's NFS client.

Installing NFS client on Ubuntu 22.04

To install an NFS client on Ubuntu 22.04, press "CTRL+ALT+T" and enter the following command:

sudo apt install nfs-common

Testing NFS share on Ubuntu 22.04

We will now put the access coordination between NFS client linuxuser and NFS server ubuntuuser to the test. Create a mount point on the NFS client machine to accomplish this:

sudo mkdir -p /mnt/nfs_clientshare

Mount the NSF share after that on the additional client system:

sudo mount 10.0.2.15:/mnt/nfs_share /mnt/nfs_clientshare

Now, we will create a few files in the nfs share directory on the linuxuser NFS server in preparation for testing the NFS share on the client system:

cd /mnt/nfs_share/
touch sample1.text sample2.text

Go to the client system after that to see the list of files that are present in the “nfs_clientshare” directory:

ls -l /mnt/nfs_clientshare/

According to the output, the ubuntuuser client's successful use of an NFS server is shown by the ability to access files:

Uninstalling NFS server on Ubuntu 22.04

Use the following command in the Ubuntu 22.04 terminal to remove the NFS client:

sudo apt remove nfs-kernel-server

Uninstalling NFS client on Ubuntu 22.04

Execute the following command in Ubuntu 22.04 terminal to uninstall the NFS client:

sudo apt remove nfs-common

The instructions for setting up, configuring, and testing an NFS server on Ubuntu 22.04 have been compiled by us.

FAQs to Install and Configure an NFS Server on Ubuntu 22.04

What are the system requirements for NFS Server on Ubuntu 22.04?

NFS Server has minimal system requirements, including Ubuntu 22.04 or a compatible version, a stable network connection, and sufficient disk space for file storage.

How can I add client access to NFS Server on Ubuntu 22.04?

Add client access to NFS Server by modifying the /etc/exports file and specifying the IP address or hostname of the client along with the desired permissions.

How do I start and stop NFS Server on Ubuntu 22.04?

Start NFS Server by running the command sudo systemctl start nfs-kernel-server and stop it with sudo systemctl stop nfs-kernel-server in the terminal.

Can I secure NFS Server on Ubuntu 22.04?

Yes, you can secure NFS Server on Ubuntu 22.04 by implementing measures like configuring firewall rules, enabling encryption, and setting up user authentication.

How can I troubleshoot NFS Server issues on Ubuntu 22.04?

Troubleshoot NFS Server issues by checking server logs with the journalctl command, ensuring proper network connectivity, and verifying file and directory permissions.

Can I access NFS Server from Windows machines?

Yes, NFS Server on Ubuntu 22.04 can be accessed from Windows machines using third-party NFS clients like NFS Client for Windows or WinNFSd.

How can I mount an NFS share on Ubuntu 22.04?

Mount an NFS share on Ubuntu 22.04 by using the mount command with the NFS server IP address or hostname, along with the directory path to mount the share.

Conclusion

We hope this detailed tutorial helped you understand how to install and configure NFS Server on Ubuntu 22.04.

If you have any suggestions or queries, kindly leave them in the comments section.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.