====== Creating NFS shares between two linux machines ======
# Install nfs server
sudo apt update
sudo apt install nfs-kernel-server
# Create share directory
sudo mkdir -p /srv/nfs/share
sudo chown -R nobody:nogroup /srv/nfs/share
sudo chmod 777 /srv/nfs/share
# Edit exports file
sudo nano /etc/exports
/srv/nfs/share client-ip-or-subnet(rw,sync,no_subtree_check,no_root_squash)
# Restart the server
sudo exportfs -ra
sudo systemctl restart nfs-kernel-server
# List exports
showmount -e
# Expected output:
Export list for :
/srv/nfs/share 192.168.1.0/24
# Install nfs client
sudo apt update
sudo apt install nfs-common
# Create mount point
sudo mkdir -p /mnt/nfs_share
# Test
sudo mount -t nfs server-ip:/srv/nfs/share /mnt/nfs_share
df -h | grep nfs
# If it works, unmount it
sudo umount /mnt/nfs_share
# Edit fstab. Add mountpoint
server-ip:/srv/nfs/share /mnt/nfs_share nfs defaults,_netdev 0 0
# Reload systemctl and mount
sudo systemctl daemon-reload
sudo mount -a
It helps if users on both sides have the same UID
# Get IDs
id username
# Expected output
uid=1000(user1) gid=1000(user1) groups=1000(user1)
# Set IDs
sudo usermod -u 1000 username
sudo groupmod -g 1000 username