Post Image

Ubuntu NFS Server

In this post I walk through the steps to create an NFS server in Ubuntu Linux. You can accomplish these steps with little Linux knowledge and should only take you less than 10 minutes.

 

Prerequisites

  • A Ubuntu Linux server installed and running that you have access to
  • Firewall on server that allows connections to NFS or the firewall temporarily disabled if it blocks the connection
    • You will not want to leave the firewall disabled permanently, only disable it to test if your ruleset is what is blocking the connections.

 

Install the NFS Server Packages

The command below will install the package that is the NFS server.

$ sudo apt install nfs-kernel-server

 

Create Directory to Share on the Server

Create a directory on your server that you want to share out. It is advised to have this be mounted on a secondary drive so if it fills up your server wont crash.

$ sudo mkdir -p /var/nfs/shared

In addition to help stop the root user on a client doing things as root on the server you will want to remove the user owner and group owner.

$ sudo chown nobody:nogroup /var/nfs/shared

 

Configure NFS Share

The configuration for the NFS shares is stored in /etc/exports edit the file with a text editor and add a line similar to below.

#directory_to_share    client_ip_or_subnet(share options)

/var/nfs/shared/    192.168.10.5(rw,sync)

You can see the first line is commented out but demonstrates the format. The last line is what shares out my NFS share. This shares out my folder to 192.168.10.5 with the read/write option and sync option.

Lastly to make this share take effect you need to restart the NFS server

# sudo systemctl restart nfs-kernel-server

 

At this point your server is hosting your specified directory to your specified clients and you can attempt a connection and start storing files there. If you continue to have questions please leave a comment and I can clear up any confusion!

 

 



Comments (0)
Leave a Comment