Back to articles

Setting up NFS fileshare - Ubuntu

Published: 2025-02-17

I recently was referring to my smb article to re-setup some shares and ran into issues. I’m not sure why but the same steps that worked months ago are no longer working for me now.

Since Windows isn’t in the loop here, I figured I’d look up a native Linux way to setup a share from Linux to Linux.

It seems like NFS was just the ticket.

1. Install NFS

sudo apt update
sudo apt install nfs-kernel-server

2. Create your directory if you don’t already have it

mkdir /home/username/share

3. Edit the NFS config file

sudo nano /etc/exports

4. Add a modified version of the line below

/home/username/share 192.168.1.0/24(rw,sync,no_subtree_check)

Obviously the first section is the full location of the folder you want to share.

Next is the network you want to share it to. a /24 network means, in this example, that any IP address starting with 192.168.1 will be able to access the share. You can narrow this down or increase scope via CIDR notation

The options in the brackets are standard options.

rw so that you can readwrite to it. Could be ro if you prefer to set it to read only.

sync ensures changes are written to disk immediatly so as to not have a delay across the share.

no_subtree_checking is just a performance improver.

5. Restart NFS service

sudo systemctl restart nfs-kernel-server

Now, the share is setup

Flip to the other linux computer that you want to connect to it from.

6. Install nfs-common

sudo apt install nfs-common

7. Restart the service

sudo systemctl restart nfs-kernel-server

8. Make a folder that you will mount the share into

mkdir /home/username/remoteShare

9. Finally, mount the share

sudo mount 192.168.1.1:/home/username/share /home/username/remoteShare

Note the IP address is that of the first computer you set this share up on WITH the full location of the shared folder after it.

The second location is the folder on the second computer you want to mount the remote share to.

ip a

Will provide the IP if you don’t know it.

But wait! There’s more.

To ensure it’s persistent over reboots you need modify /etc/fstab file.

10. Open the /etc/fstab file:

sudo nano /etc/fstab

11. Add the NFS share entry:

192.168.1.1:/home/username/share /home/username/remoteShare nfs defaults 0 0