How to install and configure NFS Server and Client

The NFS is a system for file sharing over the network.

Here, we will configure an NFS server and a client.

Attention, NFS requires a modification on Proxmox if you are using containers. This will not be the case here; we will use VMs instead.

Serveur

On the machine that will serve as the server, install nfs-kernel-server

apt-get install nfs-kernel-server

Next, create a folder that will serve as the shared folder

mkdir -p /media/data

Then assign the folder to nobody:nogroup so that the client can read and write

chown nobody:nogroup /media/data

Then modify the exports file to add the newly created folder to the share

nano /etc/exports

Then add the following line

/media/data          10.10.10.0/24(rw,sync,no_subtree_check)

Here, we only allow machines from the 10.10.10.0 network to mount the directory.

For other options, please refer to the NFS manual.

Then update the changes

exportfs -a

Your server is now ready to host a client on the /media/data folder.

Client

On the machine that will serve as the client, install nfs-common

apt-get install nfs-common

Next, create the folder that will serve as the mount point

mkdir -p /media/nfs

Modify the fstab file to mount the server’s directory

nano /etc/fstab

Then add the following line

10.10.10.2:/media/data /media/nfs nfs4 auto,_netdev,nofail,retrans=4,timeo=10

10.10.10.2 is our NFS server; here we mount the media/data folder from the NFS server to the /media/nfs folder on our client.

Reload the fstab file

mount -av

Your network folder is now operational 🙂

Leave a Comment