Setup NFS server on Debian
sudo apt install -y nfs-kernel-server nfs-common
Configure NFSv4 in /etc/default/nfs-common.
NEED_STATD="no"
NEED_IDMAPD="yes"
Configure NFSv4 in /etc/default/nfs-kernel-server. Disable NFSv2 and NFSv3.
RPCNFSDOPTS="-N 2 -N 3"
RPCMOUNTDOPTS="--manage-gids -N 2 -N 3"
sudo systemctl restart nfs-server
Configure Firewalld.
sudo firewall-cmd --zone=public --permanent --add-service=nfs
sudo firewall-cmd --reload
Setup pseudo filesystem and exports.
sudo mkdir /shared
sudo chown -R nobody:nogroup /shared
Add exported directory to /etc/exports.
/shared <ip address of client>(rw,no_root_squash,no_subtree_check,crossmnt,fsid=0)
Create the NFS table.
sudo exportfs -a
Setup NFS client on Debian
sudo apt install -y nfs-common
Create shared directory.
sudo mkdir -p /mnt/shared
Mount NFS exports. We’ll assume the IP address of the NFS server is 10.0.0.64.
sudo mount.nfs4 10.0.0.64:/ /mnt/shared
Note that the
10.0.0.65:/is relative to the exported directory. So/mnt/sharedon the client is/sharedon the server. If you try to mount withmount -t nfs 10.0.0.64:/shared /mnt/sharedyou will get a no such file or directory error.
/etc/fstab
10.0.0.64:/ /mnt/shared nfs4 soft,intr,rsize=8192,wsize=8192
sudo systemctl daemon-reload
sudo mount -av
Setup NFS server on FreeBSD
Edit /etc/rc.conf.
nfs_server_enable="YES"
nfs_server_flags="-u -t -n 4"
rpcbind_enable="YES"
mountd_flags="-r"
mountd_enable="YES"
Edit /etc/exports.
/data1 -alldirs -mapall=user1 host1 host2 host3
/data2 -alldirs -maproot=user2 host2
Start the services.
sudo service rpcbind start
sudo service nfsd start
sudo service mountd start
After making changes to the exports file, you need to restart NFS for the changes to take effect.
kill -HUP `cat /var/run/mountd.pid`
Setup NFS client on FreeBSD
Edit /etc/rc.conf.
nfs_client_enable="YES"
nfs_client_flags="-n 4"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"
Mount NFS share on client with systemd
Create a file at /etc/systemd/system/mnt-backup.mount.
[Unit]
Description=borgbackup NFS share from FreeBSD
DefaultDependencies=no
Conflicts=umount.target
After=network-online.target remote-fs.target
Before=umount.target
[Mount]
What=10.0.0.119:/coffeeNAS/borgbackup/repositories
Where=/mnt/backup
Type=nfs
Options=defaults,vers=3
[Install]
WantedBy=multi-user.target