Check out this guy’s mount/umount script for network availability:
https://www.fanninger.at/thomas/blog/mount-a-nfs-share-with-systemd
Also check out RedHat regarding autofs
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/System_Administration_Guide/s1-nfs-mount.html
Mostly from: https://ubuntuforums.org/showthread.php?t=1272450
Install
sudo apt install nfs-kernel-server
Setup folders to serve,
gksudo gedit /etc/exports
#{path to share} {network number}/{netmask}{access(rw) or (ro)}
# to make “/home” available for everyone in the network
/home 192.168.0.0/255.255.255.0(rw)
# save the file and restart the NFS server
sudo /etc/init.d/nfs-kernel-server restart
or with systemd
sudo systemctl restart nfs
In my case to share folders with NFS
gksudo gedit /etc/exports
/media/Closed 10.141.229.0/255.255.255.0(rw)
/media/Office-Files 10.141.229.0/255.255.255.0(rw)
Setup computer to mount the files
# sudo mount {server ip}:{share name} {path you want it mounted to}
sudo mount 10.141.229.10:/media/Closed /mnt/Closed
# for /etc/fstab ??? from https://bbs.archlinux.org/viewtopic.php?id=158200
This worked:
10.141.229.10:/media/Closed /mnt/closed nfs4 noauto,users,x-systemd.device-timeout=7s,timeo=14,intr 0 0
10.141.229.10:/media/Office-Files /mnt/office_files nfs4 noauto,users,x-systemd.device-timeout=7s,timeo=14,intr 0 0
after editing fstab use the following to reload the mount devices
sudo systemctl daemon-reload
sudo systemctl restart remote-fs.target
the following didn’t work:
10.141.229.10:/Closed /mnt/Closed /mnt/Closed nfs4 noauto,users,x-systemd.device-timeout=7s,rsize=8192,wsize=8192,timeo=14,intr 0 0
or
10.141.229.10:/media
/Closed /mnt/Closed nfs4 username=administrator,password=pass 0 0
or
10.141.229.10:/media/Closed /mnt/Closed nfs4 username=xxxxx,password=xxxx,noauto,users,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,hard,intr,noatime 0 0
or from https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-16-04
auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0