Setup NFS server on Debian
sudo apt install -y nfs-kernel-server nfs-commonConfigure 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-serverConfigure Firewalld.
sudo firewall-cmd --zone=public --permanent --add-service=nfs
sudo firewall-cmd --reloadSetup pseudo filesystem and exports.
sudo mkdir /shared
sudo chown -R nobody:nogroup /sharedAdd 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 -aSetup NFS client on Debian
sudo apt install -y nfs-commonCreate shared directory.
sudo mkdir -p /mnt/sharedMount NFS exports.
sudo mount.nfs4 <ip address of server>:/ /mnt/sharedNote that the
:/is relative to the exported directory. So/mnt/sharedon the client is/sharedon the server. If you try to mount withmount -t nfs:/shared /mnt/sharedyou will get a no such file or directory error.
/etc/fstab
<ip address of server>:/ /mnt/shared nfs4 soft,intr,rsize=8192,wsize=8192sudo systemctl daemon-reload
sudo mount -avSetup 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 host2Start the services.
sudo service rpcbind start
sudo service nfsd start
sudo service mountd startAfter 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