Tutorial Configure Nfs

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

How to Install and Configure an NFS Server on

Ubuntu 22.04
By Darshita Daga & Sumit Patel --- On Jul 3, 2023

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.

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.

©ms_anna/1-2023_2024
1
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/

©ms_anna/1-2023_2024
2
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

©ms_anna/1-2023_2024
3
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:

©ms_anna/1-2023_2024
4
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.

Source: https://vegastack.com/tutorials/how-to-install-and-configure-an-nfs-server-on-
ubuntu-22-04/

©ms_anna/1-2023_2024
5

You might also like