Linux: Creating an NFS Share

Sharing data across multiple computers can be achieved in many different ways, in this blog post I’m going to use an Network File System (NFS) share.

Server

The server will require nfs-kernel-server installing and at least one share setting up:

apt install nfs-kernel-server

I’m going to be using the share to share out a basic HTML page via nginx, so I’m going to call the directory nginx:

mkdir /var/nfs/nginx -p

Note: In a production environment make sure to set appropriate permissions on the directory.

nfs-kernel-server has configuration under /etc/exports, which will need editing to with the details of the clients that will be connecting:

nano /etc/exports

The exports file has the format of:

/path/to/sharedfolder        ClientIPADDRESS(permissions, options)

Once the configuration has been edited, nfs-kernel-server will need restarting:

systemctl restart nfs-kernel-server

Clients

The clients will require nfs-common installing:

apt install nfs-common

The clients will need a directory to map the share to:

mkdir -p /nfs/nginx

And then will need to mount the share into the directory:

mount SERVERIPORHOSTNAME:/var/nfs/nginx /nfs/nginx

If you have multiple clients I would recommend some Ansible here to do the heavy lifting.

2 responses to “Linux: Creating an NFS Share”

  1. Proxmox: Adding A Share – GeekTechStuff Avatar

    […] Previously I wrote about adding an NFS share, its the same principles for this project. On a device (I’m using a Raspberry Pi as the share sever) create the NFS shares and share them out. […]

    Like

  2. K3s Cluster (Kubernetes) – GeekTechStuff Avatar

    […] also using an NFS share for when I want a shared volume or a volume that may exist outside of the containers ephemeral […]

    Like

Welcome to GeekTechStuff

my home away from home and where I will be sharing my adventures in the world of technology and all things geek.

The technology subjects have varied over the years from Python code to handle ciphers and Pig Latin, to IoT sensors in Azure and Python handling Bluetooth, to Ansible and Terraform and material around DevOps.

Let’s connect