I made a sh script to mount my Synology shared folders via LFS.
It works like a charm, here's the code (xxxxx stands for the IP adress of my nas)
#!/bin/sh
#Mount the following folders on Komputer with LFS protocol:
#1. data
#2. games
#3. Youtubing
sudo mount xxxxxxxxxxxx:/volume1/data /mnt/nas_media/
sudo mount xxxxxxxxxxxx:/volume1/Games /mnt/nas_games/
sudo mount xxxxxxxxxxxx:/volume1/youtubing /mnt/youtubing/
When I run the code, the folders are mounted correctly in the mounting points in /mnt/.
I created a crontab entry with
crontab -e
and i wrote the following:
#Mount useful NAS folders when starting up:
@reboot /etc/nas_mount.sh
When I reboot the system, however, the folders are not mounted. I tried inserting a sleep 30 in my script to await for all the network services to be online, to no avail.
Any ideas?
Thanks.
That is a perfect start to automatically mounting your Synology shares on Ubuntu. However, when I tried using /mnt/ on my 24.04 instance I encountered an issue which was resolved by using the directory
/media
which is reflected in the code below (creating the sub-directories for the shares below that as shown).From there in /etc/fstab create the following entries (based on your provided information in the context of the entries I have in my fstab file):
Write out the /etc/fstab file with Ctrl+O after which return to the terminal with Ctrl+X in order to attempt to mount the shares.
Try the mount with
sudo mount -a -v
in terminal (-a means all and -v means verbose).You should then be able to see that the shares are mounted in the Nautilus left panel.
If you want to see the shares on your desktop (as I have in the image below) install (if not already done so)
Extension Manager
andDesktop Icons NG (DING)
use the cog wheel and setShow external drives in the desktop
to ON and other options as desired.Of course, replace
nnn.nnn.n.nnn
with your NAS IP address and alsoxxxxxx
with your actual usernames and passwords for the Synology shares from your device.It should be noted that my Synology NAS is formatted
Ext4
in an SHR Raid configuration (the OP's is NFS) so different mount entries may be required accordingly.In the end, these entries in
fstab
worked for the NFS system format.It may also benefit you to make a backup copy of your existing fstab file.