website/content/blog/monter-un-dossier-partage-du-nas-synology-vers-un-dossier-du-raspberry-pi-4-en-nfs.en.md

4.6 KiB

title date lastupdate banner slug description
Mount a Synology NAS shared folder to a Raspberry PI 4 folder with NFS 2024-01-18 10:00:00 2024-02-08 15:05:35 /proxyPhotos?code=/blog/bob-ross/65b04b1d03f30/50.png mount-a-synology-nas-shared-folder-to-a-raspberry-pi-4-folder-with-nfs The shared folder is synchronized with Google Drive using the Cloud Sync application of the Synology NAS and thus allows Google Drive to be synchronized with the RPI
Bob Ross

1. Assign a static IP address to the NAS and the router (use static DHCP leases with Livebox)

  • xxx.xxx.xxx.xxx (NAS)
  • xxx.xxx.xxx.yyy (Wired RPI)
  • xxx.xxx.xxx.zzz (Wireless RPI)

2. On the Synology NAS host
--> Create the shared folder FOLDER on the NAS
--> Sync the FOLDER folder with a folder on Google Drive using Cloud Sync
--> Set NFS permissions on the shared folder for the RPI with read/write access for wired and wireless RPI addresses

3. On the client RPI
In the example, user = raspi
--> Update the package database

sudo apt update

--> Upgrade the system

sudo apt full-upgrade

--> Create a folder directory for mounting

sudo mkdir /home/raspi/folder

--> Granting all rights on the mounting folder and the files of the folder.

sudo chmod -R 777 /home/raspi/dossier
sudo chown -R raspi:raspi /home/raspi/dossier

--> Create a Scripts folder for the mounting script

sudo mkdir /home/raspi/Scripts

--> Create the mount-folder.sh file for mounting with Geany

sudo geany

--> Enter the code into Geany
In the mount, the -t (type) option should be followed by the used protocol, here nfs
Replace xxx.xxx.xxx.xxx with the correct value

#/bin/bash
sudo mount -t nfs xxx.xxx.xxx.xxx:/volume1/FOLDER /home/raspi/folder

--> Save in the /home/raspi/Scripts directory with the name mount-folder.sh

--> Create the service file mount-folder.service for mounting with Geany for startup automation

sudo geany

--> Enter the code into Geany

[Unit]
# Description of service: Mount NAS folder
Description=Mount NAS folder

# This service will start after the network is available
After=network-online.target

[Service]
# Command to execute to start the service: execute the bash script to mount the NAS folder
ExecStart=/bin/bash /home/frapoi/Scripts/mount-folder.sh

# Working directory to execute the command
WorkingDirectory=/home

# Restart the service on failure
Restart=on-failure

# Run the service as user 'frapoi'
User=frapoi

[Install]
# Enable this service on system startup
WantedBy=multi-user.target


--> Save in the /etc/systemd/system/ directory with the name mount-folder.service

--> Enable the mount-folder.service file

sudo systemctl enable mount-folder.service

--> Reboot the RPI

sudo reboot

The mounted folder appears on the RPI desktop.
The script can be adapted depending on the NAS used and provides the basic principle.