Network File System
On the Host
sudo apt update
sudo apt install nfs-kernel-server
Creating the Share Directories on the Host
sudo mkdir /var/nfs/general -p
ls -la /var/nfs/general
Output
drwxr-xr-x 2 root root 4096 May 14 18:36 .
sudo chown nobody:nogroup /var/nfs/general
sudo chmod 777 /var/nfs/general
Configuring the NFS Exports on the Host Server
sudo nano /etc/exports
directory_to_share client(share_option1,...,share_optionN)
/var/nfs/general client_ip(rw,sync,no_subtree_check)
/home client_ip(rw,sync,no_root_squash,no_subtree_check)
sudo systemctl restart nfs-kernel-server
Adjusting the Firewall on the Host
#sudo ufw allow from client_ip to any port nfs
sudo ufw allow from 192.168.2.1/24 to any port nfs
On the Client
sudo apt update
sudo apt install nfs-common
Creating Mount Points and Mounting Directories on the Client
sudo mkdir -p /nfs/general
sudo mkdir -p /nfs/home
sudo mount host_ip:/var/nfs/general /nfs/general
sudo mount host_ip:/home /nfs/home
df -h
Mounting an NFS File System automatically
sudo nano /etc/fstab
192.168.2.182:/var/nfs/general /var/nfs/general nfs defaults 0 0
sudo umount [mount_point]
sudo umount /var/nfs/general