Automatically mount NAS folders using NFS

I am new to linux and to EOS, using xfce if that is relevant.

I want to permanently mount folders from a Synology NAS (on PC boot up and on demand) from within a local network. The NAS is active during the day and inactive during the night, so it needs to be able to re-connect on demand.

I installed AUR package nfs-utils in preparation.

Preparation on the NAS I already did:

  1. Enabled NFS service on the Synology NAS - control panel / file services / NFS
  2. Assign NFS permission to shared folders - control panel / shared folder
  3. Mount shared folders via NFS IP on my PC using these commands:

sudo mount -t nfs [Synology NAS IP address]:[mount path of shared folder] /[mount point on NFS client]

In my example, I create a folder in mnt directory and then allow read/write permission:

sudo mkdir /mnt/nas
sudo chmod +rx /mnt/nas

next I mount the folders folder1 and folder2 from NAS IP to the newly created mnt/nas directory

sudo mount -t nfs 192.1xx.xxx.xx:/volume1/folder1 /mnt/nas
sudo mount -t nfs 192.1xx.xxx.xx:/volume1/folder2 /mnt/nas

Now everytime I restart my PC I have to manually mount all folders again.
Also, if the PC is still on and the NAS is switched off, the mounted folders disappear and will not come back even if I restart the NAS.

How can I have the mounted NAS folders permanently mounted or automate the mounting process on my PC?

Add them to your /etc/fstab.
https://wiki.archlinux.org/title/NFS#Mount_using_/etc/fstab

1 Like

Use a systemd-automount in /etc/fstab.

You can add a line like this to /etc/fstab for each thing you want to share:

192.1xx.xxx.xx:/volume1/folder1 /mnt/nas/folder1 nfs x-systemd.automount,x-systemd.device-timeout=10,timeo=14,x-systemd.idle-timeout=1min 0 0
1 Like

Thank you both Cphusion and dalto, the suggested solution works as intended.

I have opened /etc/fstab using nano

sudo nano /etc/fstab

and saved my changes with [ctrl]+[s] afterwards.

I added the line suggested by dalto, each of my NAS folders got a separate line. The addition was done at the end of the file.

192.1xx.xxx.xx:/volume1/folder1 /mnt/nas/folder1 nfs x-systemd.automount,x-systemd.device-timeout=10,timeo=14,x-systemd.idle-timeout=1min 0 0

systemctl needed to be reloaded due to the change:

systemctl-daemon reload

after reloading, mount everything at once listed in /etc/fstab using:

sudo mount -a

The mounting now works as intended, thank you for the help.

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.