Mount a remote NFS share on local Linux - Sat, Mar 1, 2025
This document is paired with a video linked below. We are going to mount a remote NFS share.
The general idea is that you have a Linux server with files that you wish to share with other Linux clients on the network. You will use NFS for that.
Here are all of the commands that you are going to use that were described in the video:
### install nfs
sudo apt update
sudo apt install nfs-kernel-server
### prepare shared folder, raidz2 in my case
sudo mkdir -p /jaglenac
sudo chown -R nobody:nogroup /jaglenac
sudo chmod 777 /jaglenac
### edit exports file
nano /etc/exports
/jaglenac 192.168.99.13(rw,sync,no_subtree_check) 192.168.99.20(rw,sync,no_subtree_check)
### apply changes and restart
sudo exportfs -ra
sudo systemctl restart nfs-server
### install client side NFS
sudo apt update
sudo apt install nfs-common
### make folder
sudo mkdir -p /jaglenac
### edit /etc/fstab
192.168.99.14:/jaglenac /jaglenac nfs4 defaults,_netdev,x-systemd.automount 0 0
systemctl daemon-reload
mount /jaglenac
df
umount /jaglenac
### install iptables
sudp apt install iptables
### configure firewall
sudo iptables -A INPUT -p tcp -s 192.168.99.13 --dport 2049 -j ACCEPT
sudo iptables -A INPUT -p tcp -s 192.168.99.20 --dport 2049 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 2049 -j DROP
### test if the access still works?
mount /jaglenac
df
### install persistence daemon
sudo apt install iptables-persistent
// sudo iptables-save > /etc/iptables/rules.v4
reboot
### check fireall rules are active
iptables -L
### check the client side
mount /jaglenac
df
reboot
df
DO NOT copy paste the entire block, but watch the video instead and understand which command goes to which server/client machine.
Please watch the acompanying video on your prefered video platform:
- PeerTube: https://tux-edu.tv/w/rgNYJXFTcVFb2fDXcBq6xQ
- Odysee: https://odysee.com/@LinuxRenaissance:1/nfs:fc
- YouTube: https://youtu.be/LBt0O43c3tc