How to Install NFS Server on Linux Ubuntu 20.04. NFS also called “Network File System” is a file sharing protocol developed by Sun’s Microsystems. It allows users to share files across the Local Area Network. It is very useful when you need to share common data to multiple clients. NFS provides a convenient way to access the remote storage over the network and mount them on the client system.
By default, the NFS protocol does not provide any user authentication or encryption. You can restrict the NFS access based on the client’s IP and hostname. NFS allows the client system to view, store and update files on the remote system.
Advantages of using NFS
Simple and low cost solution for network file sharing.
Easy to install and set up.
Enables central administration and management of files.
Reduces disk space requirements for clients.
In this post, we will show you how to install the NFS server on Ubuntu 20.04.
You can verify the status of the NFS service using the following command:
systemctl status nfs-server
Sample output:
● nfs-server.service - NFS server and services
Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
Active: active (exited) since Thu 2021-11-04 08:45:06 UTC; 5s ago
Main PID: 4198 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 2353)
Memory: 0B
CGroup: /system.slice/nfs-server.service
Nov 04 08:45:05 ubuntu2004 systemd[1]: Starting NFS server and services...
Nov 04 08:45:06 ubuntu2004 systemd[1]: Finished NFS server and services.
Create a Shared Directory on NFS Server
Next, you will need to create a directory on the NFS serve that you want to share with the client systems. Let’s create a directory named /nfs_share using the following command:
mkdir /nfs_share
Next, assign proper ownership and permissions to the /nfs_share directory so it can be accessible from the client machines.
Save and close the file when you are finished. The above configuration will allow all clients in the 192.168.0.0 network to access the NFS share.
Where:
rw – Assign read and write
sync – Write changes to disk before applying them
no_subtree_check – Avoid subtree checking
Next, run the following command to export the shared directory and make it available to all client systems.
export -a
systemctl restart nfs-server
Configure Firewall
If the UFW firewall is installed and configured on your server. Then, you will need to allow NFS service to the client network. You can allow it by running the following command:
ufw allow from 192.168.0.0/24 to any port nfs
Next, reload the UFW firewall to apply the changes.
At this point, the NFS server is installed and configured. Now, you will need to install the NFS client package on the client system. You can install it by running the following command:
apt-get install nfs-common -y
Once the NFS client package is installed, you can proceed to the next step.
Mount NFS Share on Client System
First, you will need to create a directory on the client system on which you want to mount the NFS share from the server.
Let’s create a directory named client_share inside /opt directory:
mkdir /opt/client_share
Now, mount the NFS share directory to the client directory using the following command:
mount -t nfs -o nfsvers=3 192.168.0.100:/nfs_share /opt/client_share
Where: 192.168.0.100 is the IP address of the NFS server.
Next, verify that the NFS share directory is mounted using the following command:
df -h
You should see your mounted share in the last line of the following output:
Installing NFS Server on Linux Ubuntu 20.04 Conclusion
In the above post, we explained how to install the NFS server on Ubuntu 20.04. We also explained how to share a directory using NFS and mount it on the client machine. I hope this will help you to share files using NFS on your network.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
00votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.