Last updated: 2019-02-24
FreeBSD Handbook Network File System (NFS)
I use a few virtual machines and share files through NFS shares.
Create the share on your host machine by adding to /etc/rc.conf
#nfs
rpcbind_enable="YES"
nfs_server_enable="YES"
mountd_flags="-r"
mountd_enable="YES"
nfsv4_server_enable="YES"
nfsuserd_enable="YES"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"
Then add to /etc/exports (note: the ip addresses are for my virtual machines; bridged is easier than NAT to do this in VirtualBox but the networking can be SLOW)
/nfs 192.168.1.99 192.168.1.98
V4: /
Create a shared directory somewhere (/nfs or /home/darren/nfs)
mkdir /nfs
chmod 777 /nfs
chown darren:darren /nfs (not needed if /home/darren/nfs)
Start the nfs service
service nfsd restart
And the mountd service anytime you change /etc/exports
service mountd reload
On an Ubuntu guest machine
How To Set Up an NFS Mount on Ubuntu 18.04
sudo apt install nfs-common
Add to /etc/fstab (note: the ip address is my host machine; use your own ip address and directory names)
192.168.1.7:/nfs /home/darren/nfs nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
Make the mount point in the guest machine
mkdir /home/darren/nfs
If the share does not automount, mount it using correct ip address and directory names
sudo mount -t nfs4 192.168.1.7:/nfs /home/darren/nfs
Something need fixing? Contact me: