Setup NFS Server
Minimum requirements
- Linux, this page will cover Alpine, Debian and RHEL based configurations
- 1-2 CPU cores
- 1GB memory
- 10gb storage (All depends on what your applications will require)
Install the required packages
OS:
sudo apk update # Update apk cache
sudo apk add nfs-utils # Install NFS utils/server
sudo rc-update add nfs # Start NFS server on bootsudo apt update # Update apt cache
sudo apt install -y nfs-kernel-server rpcbind # Install NFS server
sudo systemctl enable --now nfs-server rpcbind # Start and enable nfs-server on bootsudo yum -y update # Update yum cache
sudo yum -y install nfs-utils # Install NFS server
sudo systemctl enable --now nfs-server rpcbind # Start and enable nfs-server on bootConfigure shares
This guide will use /share/nfs as an example, this guide wil also be allowing access to the share from 10.10.1.0/28 only
sudo mkdir -p /share/nfs
# mount disk via fstab if you are using a dedicated disk, not covered here
echo '/share/nfs 10.10.1.0/28(rw,no_root_squash,async,fsid=0,no_subtree_check)' | sudo tee -a /etc/exportsIf you want to enable a share to multiple ip’s or subnets you can add another ip/option block to the line e.g.
/etc/exports
/share/nfs 10.10.1.0/28(rw,no_root_squash,async,fsid=0,no_subtree_check) 192.168.1.22(rw,no_root_squash,async,fsid=0,no_subtree_check)Apply the configuration change
Run sudo exportfs -rav to apply the share changes from the exports file. (no service restart required.)