How To Configure NFS Server

Yomi AdefemiYomi Adefemi
2 min read

Configuration of NFS Server

Step 1: Install NFS Kernel Server

Before installing the NFS Kernel server, update your system’s repository index with the following command:

sudo apt-get update

This ensures you install the latest available version of software from the Ubuntu repositories. Now, install the NFS Kernel Server:

sudo apt install nfs-kernel-server

Step 2: Create the Export Directory

Create the directory you want to share:

sudo mkdir -p /mnt/share/

#Set the appropriate permissions to allow all clients to access the directory:

sudo chown nobody:nogroup /mnt/share/

sudo chmod 777 /mnt/share/

Step 3: Configure the NFS Exports File

Edit the NFS exports file to assign server access to clients:

sudo vi /etc/exports

Add the following line to export the directory to all clients:

#/mnt/share/ (rw,sync,no_subtree_check,no_root_squash)

/mnt/share/ *(rw,sync,no_subtree_check,no_root_squash)

Alternatively, specify a particular client or a range of clients using their IP addresses or CIDR notation.

Step 4: Export the Shared Directory

Apply the changes and restart the NFS Kernel Server:

sudo exportfs -a

sudo systemctl restart nfs-kernel-server

Step 5: Configure the Firewall

Open the firewall for NFS traffic on port 2049:

sudo ufw allow from <clientIP> to any port nfs

Configuring the Client Machine

Step 1: Install NFS Common

Update the system’s repository index:

sudo apt-get update

Install the NFS Common package:

sudo apt-get install nfs-common

Step 2: Create a Mount Point for the NFS Share

Create the directory where the NFS share will be mounted:

sudo mkdir -p /mnt/mountfolder_client

Step 3: Mount the Shared Directory

sudo mount <serverIP>:/mnt/share/ /mnt/mountfolder_client

Mount the shared directory from the NFS server:

Replace <serverIP> with the IP address of your NFS server (e.g., 306.356.313.419).

0
Subscribe to my newsletter

Read articles from Yomi Adefemi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Yomi Adefemi
Yomi Adefemi

I'm a DevOps Engineer with a Passion for Cloud Technology and a Love for Teaching.