Discover how to set up an NFS mount on Ubuntu 24.04. Our experienced NFS Support team is ready to assist.
How to Set Up an NFS Mount on Ubuntu 24.04
Sharing files across machines in a network can be made easy with NFS (Network File System). If you’re running Ubuntu 24.04, setting up an NFS mount is an easy way to make files accessible between systems, whether for a collaborative workspace, centralized data storage, or managing multiple servers.
Users sometimes encounter issues like NFS permission denied when accessing shared directories. You can learn how to resolve it in our OpenMediaVault NFS permission denied guide.
Today, we will walk through the step-by-step process of setting up an NFS mount on Ubuntu 24.04, both on the server and the client side.
An Overview:
What is NFS?
NFS (Network File System) is a protocol that enables systems to share directories and files over a network as if they were part of the local file system. It’s commonly used in enterprise environments to streamline access to shared data, reduce redundancy, and improve collaboration across devices on the same LAN.
Prerequisites
Before we begin, we need:
- One or more systems running Ubuntu 24.04
- Sudo privileges on both server and client machines
- The IP address of the server that will host the shared directory
Step-by-Step Guide
- We will start by installing the NFS server package on the machine that will host the shared directory:
sudo apt update
sudo apt install nfs-kernel-server
- Once installed, confirm that the NFS server is active:
sudo systemctl status nfs-server
- Next, create the directory we want to share. For example:
sudo mkdir -p /srv/nfs/nfs_share
- We need to adjust permissions to make the directory accessible:
sudo chown nobody:nogroup /srv/nfs/nfs_share
sudo chmod 777 /srv/nfs/nfs_share
- Then, open the NFS exports configuration file:
sudo nano /etc/exports
- Now, add the following line, replacing `CLIENT_IP` with the IP address of the client machine:
/srv/nfs/nfs_share CLIENT_IP(rw,sync,no_subtree_check)
Here:
- rw: Enables read/write access
- sync: Ensures changes are committed to disk before completing operations
- no_subtree_check: Disables subtree checking for better performance
- Then, apply the export settings:
sudo exportfs -a
- Also, ensure the NFS server starts at boot and is currently running:
sudo systemctl enable nfs-server
sudo systemctl start nfs-server
- If we are using UFW (Uncomplicated Firewall), allow NFS traffic:
sudo ufw allow from CLIENT_IP to any port nfs
- Now, install the necessary NFS utilities on the client machine:
sudo apt update
sudo apt install nfs-common
If you encounter package errors such as “Unable to find a match: nfs-utils-lib”, here’s how to fix the nfs-utils-lib issue.
- Then, create a local directory to mount the shared NFS folder:
sudo mkdir -p /mnt/nfs_share
- Now, mount the shared directory using the server’s IP address:
sudo mount SERVER_IP:/srv/nfs/nfs_share /mnt/nfs_share
- To verify the mount:
df -h
We will see the NFS share listed among your mounted filesystems. You might occasionally face mount failures like Network Error 53. Check out our guide on resolving NFS Network Error 53 for help.
- We can also mount NFS automatically on boot by adding it to the `/etc/fstab` file:
sudo nano /etc/fstab
Add the following line:
SERVER_IP:/srv/nfs/nfs_share /mnt/nfs_share nfs defaults 0 0
- Save and exit. The mount will now persist across reboots.
Be aware of issues such as a file ID change on the NFS server, which can interrupt file access. Here’s how to fix the fileid changed error.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
Setting up an NFS mount on Ubuntu 24.04 is an easy way to streamline file sharing across systems.
This guide, created by our Support Engineers, provides instructions on configuring NFS mounts on Ubuntu 24.04.
0 Comments