Setup NFS server on Debian
1sudo apt install -y nfs-kernel-server nfs-commonConfigure NFSv4 in /etc/default/nfs-common.
1NEED_STATD="no"
2NEED_IDMAPD="yes"Configure NFSv4 in /etc/default/nfs-kernel-server. Disable NFSv2 and NFSv3.
1RPCNFSDOPTS="-N 2 -N 3"
2RPCMOUNTDOPTS="--manage-gids -N 2 -N 3"1sudo systemctl restart nfs-serverConfigure Firewalld.
1sudo firewall-cmd --zone=public --permanent --add-service=nfs
2sudo firewall-cmd --reloadSetup pseudo filesystem and exports.
1sudo mkdir /shared
2sudo chown -R nobody:nogroup /sharedAdd exported directory to /etc/exports.
1/shared <ip address of client>(rw,no_root_squash,no_subtree_check,crossmnt,fsid=0)Create the NFS table.
1sudo exportfs -aSetup NFS client on Debian
1sudo apt install -y nfs-commonCreate shared directory.
1sudo mkdir -p /mnt/sharedMount NFS exports.
1sudo 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
1<ip address of server>:/ /mnt/shared nfs4 soft,intr,rsize=8192,wsize=81921sudo systemctl daemon-reload
2sudo mount -avSetup NFS server on FreeBSD
Edit /etc/rc.conf.
1nfs_server_enable="YES"
2nfs_server_flags="-u -t -n 4"
3rpcbind_enable="YES"
4mountd_flags="-r"
5mountd_enable="YES"Edit /etc/exports.
1/data1 -alldirs -mapall=user1 host1 host2 host3
2/data2 -alldirs -maproot=user2 host2Start the services.
1sudo service rpcbind start
2sudo service nfsd start
3sudo service mountd startAfter making changes to the exports file, you need to restart NFS for the changes to take effect.
1kill -HUP `cat /var/run/mountd.pid`Setup NFS client on FreeBSD
Edit /etc/rc.conf.
1nfs_client_enable="YES"
2nfs_client_flags="-n 4"
3rpc_lockd_enable="YES"
4rpc_statd_enable="YES"Mount NFS share on client with systemd
Create a file at /etc/systemd/system/mnt-backup.mount.
1[Unit]
2Description=borgbackup NFS share from FreeBSD
3DefaultDependencies=no
4Conflicts=umount.target
5After=network-online.target remote-fs.target
6Before=umount.target
7
8[Mount]
9What=10.0.0.119:/coffeeNAS/borgbackup/repositories
10Where=/mnt/backup
11Type=nfs
12Options=defaults,vers=3
13
14[Install]
15WantedBy=multi-user.target