NFS mounting 2015 style (NAS share)

mounting a NFS share on my NAS – 2015 style using autofs instead of fstab

for great justice…

first show all shares that the server exports:

[root@media ~]# showmount -e nas.local
Export list for nas.local:
/shares/public *
/shares/andreas *
[root@media ~]#

manual mount: (quick and dirty)
[root@media ~]# mkdir /mnt/nas
[root@media ~]# mount nas.local:/shares/public /mnt/nas

if it works, make it permanent (old fashioned way using fstab)

The syntax of a fstab entry is :
[Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]

device
The device/partition (by /dev location or UUID) that contain a file system.

mount point
The directory on your root file system (aka mount point) from which it will be possible to access the content of the device/partition (note: swap has no mount point). Mount points should not have spaces in the names.

file system type
Type of file system (see LinuxFilesystemsExplained).

options
Mount options of access to the device/partition (see the man page for mount).

dump
Enable or disable backing up of the device/partition (the command dump). This field is usually set to 0, which disables it.

pass num
Controls the order in which fsck checks the device/partition for errors at boot time. The root device should be 1. Other partitions should be 2, or 0 to disable checking.

so:
server: 0 0

in our case:
nas.local:/shares/public /mnt/nas nfs rsize=8192,wsize=8192,timeo=14,intr 0 0

but it’s 2015 so let’s use autofs to mount these “on demand” using systemd (I think…)
source: https://anteru.net/2014/09/20/2480/

install and set up autofs (systemctl enable / start autofs)
in /etc/auto.master add the file system type you want to automount on demand
like this:

(desired mountpoint and config file)
/mnt/nfs /etc/auto.nfs

inside auto.nfs
public -fstype=nfs,rw,soft,tcp,nolock nas.local:/shares/public