Why
We want to be able to auto-mount our NFS share in the event of unepected shutdowns and restarts.
Goal
Make sure the the NFS share is automounted each time the server restarts.
Enable NFS service on your Synology NAS
Before accessing a shared folder with your NFS client, you must change the settings on your Synology NAS to allow sharing via NFS. Follow the steps below:
- Go to Control Panel > File Services > NFS (for DSM 7.0 and above) or SMB/AFP/NFS (for DSM 6.2 and earlier).
- Tick Enable NFS service.
- Click Apply to save the settings.
Assign NFS permission to shared folders
Before accessing any shared folders with your NFS client, you must first configure the NFS permissions of the shared folder you wish to access. Follow the steps below to change NFS permissions of the shared folders on your Synology NAS:
- Go to Control Panel > Shared Folder.
- Select the shared folder that you want to access with your NFS client and click Edit.2
- Go to NFS Permissions and click Create.
- Refer to this article to edit the permission settings.
- Click Save (for DSM 7.0 and above) or OK (for DSM 6.2 and earlier) to save the rule.
- Click Save (for DSM 7.0 and above) or OK (for DSM 6.2 and earlier) to apply the NFS permissions.
- After applying the NFS permission, you can find the mount path of the shared folder at the bottom-left of the NFS Permissions tab. The mount path should be in the following format: /[volume name]/[shared folder name]
Mount NFS share to the server with autofs
# Create a folder to mount the NFS volume to.
mkdir -p /mnt/synology
# Install autofs
sudo apt install autofs
Several files should have been created: /etc/autofs.conf -> auto.master -> auto.nfs The should look somewhat like this.
# /etc/auto.nfs
/mnt/synology 192.168.1.x:/mountname/folder
# /etc/auto.master
/- /etc/auto.nfs
# /etc/autofs.conf For our purposes the only lines that matter are:
[ autofs ]
# master_map_name - default map name for the master map.
master_map_name = /etc/auto.master
timeout = 300
[ amd ]
# Override the internal default with the same timeout that
# is used by the override in the autofs configuration, sanity
# only change.
#
dismount_interval = 300