Dogga85
Posts: 28
Joined: Mon Dec 19, 2016 10:15 pm

How do I mount NAS Network Shares

Thu Jun 27, 2019 10:49 pm

Hey All,

Setting up my RPi 3 B+ as a Plex Server. I need to mount my NAS Network Media Shares (\\synologyds215\ Movies and \\synologyds215\TV Shows). I have created directories /home/pi/synologyds215/Movies and /home/pi/synologyds215/TVShows.
I'm assuming I need to edit the fstab file (via command sudo nano /etc/fstab) with directories and credentials for the network shares, exactly what commands do I need? Sorry still a noobie to Linux

bls
Posts: 2702
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: How do I mount NAS Network Shares

Fri Jun 28, 2019 1:55 pm

You're absolutely on the right track. The general format for fstab CIFS entries is:

Code: Select all

//remotehost/remoteshare /localdir cifs options
The remote system credentials are supplied as options using either username= and password= options in fstab, or via a credentials= option pointing to a file that has

Code: Select all

username=remoteusername
password=remotepassword
A real-life example from my pi:

Code: Select all

//xunil/kits /k   cifs credentials=/usr/local/bin/mycreds
where mycreds contains:

Code: Select all

username=me
password=mycomplexpassword
This isn't totally secure since you have a system's username/password combination in a file (either fstab or some other file), so make sure that it's appropriately protected (e.g., chmod 600 /usr/local/bin/mycreds)

If you care about uid/gids as viewed on the pi, you may need to use option vers=1.0. All dependent on the synology configuration, but if you're only doing read access, it probably doesn't matter much.

Also, see man mount.cifs for a description of the various cifs options.
Last edited by bls on Fri Jun 28, 2019 7:00 pm, edited 1 time in total.
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Dogga85
Posts: 28
Joined: Mon Dec 19, 2016 10:15 pm

Re: How do I mount NAS Network Shares

Fri Jun 28, 2019 10:50 pm

Thankyou so much!!! So mine will be:

//synologyds215/TV Shows /home/pi/synologyds215/TVShows cifs credentials=/home/pi/smb.cred

//synologyds215/Movies /home/pi/synologyds215/Movies cifs credentials=/home/pi/smb.cred

Dogga85
Posts: 28
Joined: Mon Dec 19, 2016 10:15 pm

Re: How do I mount NAS Network Shares

Fri Jun 28, 2019 11:19 pm

Dang it, I just tried the code I typed above and it doesn't appear to have worked. I have rebooted and the folders still not showing anything. Is it because my SMB share folder TV Shows has a space in the name maybe or have I typed the code wrong?

Andyroo

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 12:02 am

try

Code: Select all

//synologyds215/TV\40Shows /home/pi/synologyds215/TVShows cifs credentials=/home/pi/smb.cred
40 is code for a white space

bls
Posts: 2702
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 12:04 am

Or get rid of the spaces in the share names. Much easier than trying to figure out the magic incantation to make it work in every use case.
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Dogga85
Posts: 28
Joined: Mon Dec 19, 2016 10:15 pm

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 12:07 am

Thankyou, I now have

Code: Select all

//synologyds215/TV\40Shows /home/pi/synologyds215/TVShows   cifs credentials=/home/pi/smb.cred
//synologyds215/Movies /home/pi/synologyds215/Movies   cifs credentials=/home/pi/smb.cred
Still nothing :( I have this code directly under the PARTUUID line in fstab, is this correct?

Andyroo

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 12:18 am

Its possible that the fstab routines cannot access /home/pi/smb.cred

You could try copying it to /root using

Code: Select all

sudo cp smd.cred /root
and amending the lines to point to this or try

Code: Select all

//synologyds215/TV\40Shows /home/pi/synologyds215/TVShows   cifs username=synologyuser,password=synologypassword
The other thing is DNS may not have kicked in so you could try the IP address of the Synology.

My box is off the network at the mo (building work) - I may be able to get it up and running on Sunday if you are still stuck :oops:

Dogga85
Posts: 28
Joined: Mon Dec 19, 2016 10:15 pm

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 12:40 am

Thankyou for all of your help, I have tried all of that and it's still not showing anything in the folders :(

bls
Posts: 2702
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 1:38 am

Let's see what the error is.

Please do the following in a terminal window immediately after you try to mount the share:

Code: Select all

journalctl ---no-pager | tail -n 50
and copy/paste the output into your reply to this message.
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Dogga85
Posts: 28
Joined: Mon Dec 19, 2016 10:15 pm

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 1:50 am

I'll try that when I get home. When you say "immediately after I try to mount the drives", what do you mean? All I'm doing is editing the fstab in nano and then rebooting the Pi, should I be manually doing something else after that to try mount them?

bls
Posts: 2702
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 2:30 am

OK, thanks for clarifying your scenario. Please do the following in a terminal window instead of rebooting:

Code: Select all

sudo mount -a
sudo journalctl ---no-pager | tail -n 50 
The mount -a command will try to ensure that all entries in fstab are mounted. The 2nd command will grab the last 50 lines of the system journal, and should include any errors thrown from the mount command.
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

LTolledo
Posts: 6657
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 2:47 am

this is how it appears on mine:

Code: Select all

//192.168.101.130/share  /mnt/synchdd     cifs    credentials=/root/.cifuser,nofail,ro,vers=1.0,x-systemd.automount   0  0
note that I use IP address instead...
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

Dogga85
Posts: 28
Joined: Mon Dec 19, 2016 10:15 pm

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 4:43 am

This is what i got
pi@raspberrypi:~ $ sudo mount -a
mount error(95): Operation not supported
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mount error(95): Operation not supported
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
pi@raspberrypi:~ $ sudo journalctl ---no-pager | tail -n 50
journalctl: unrecognized option '---no-pager'

Dogga85
Posts: 28
Joined: Mon Dec 19, 2016 10:15 pm

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 4:50 am

this is what my fstab file contains

Code: Select all

proc            /proc           proc    defaults          0       0
PARTUUID=949f78a3-01  /boot           vfat    defaults          0       2
PARTUUID=949f78a3-02  /               ext4    defaults,noatime  0       1
//192.168.0.2/Movies /home/pi/synologyds215/Movies     cifs    credentials=/root/smb.cred
//192.168.0.2/TVShows /home/pi/synologyds215/TVShows     cifs    credentials=/root/smb.cred
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

Dogga85
Posts: 28
Joined: Mon Dec 19, 2016 10:15 pm

Re: How do I mount NAS Network Shares

Sat Jun 29, 2019 7:40 am

OK i just figured it out, FINALLY hahaha. I had to add vers1.0, so my code had to be

Code: Select all

//192.168.0.2/Movies /home/pi/synologyds215/Movies     cifs    credentials=/root/smb.cred,vers=1.0
//192.168.0.2/TVShows /home/pi/synologyds215/TVShows     cifs    credentials=/root/smb.cred,vers=1.0

Donnelly
Posts: 129
Joined: Wed Aug 21, 2019 10:54 pm

Re: How do I mount NAS Network Shares

Fri Nov 08, 2019 4:12 pm

Good Day,
I have the most similar problem and am also very new to Raspberry. I am trying to automount my RPi4 NAS share (donnellyshare) to my other RPi4 Plex Media Server.

I have reviewed this thread and tried the various suggestions, but no joy.

I have also used the following links:
https://pimylifeup.com/raspberry-pi-samba/
https://pimylifeup.com/raspberry-pi-plex-server/
https://tynick.com/blog/09-22-2019/plex ... erry-pi-4/
https://www.codedonut.com/raspberry-pi/ ... pberry-pi/

My /etc/fstab file:

proc /proc proc defaults 0 0
PARTUUID=5e3da3da-01 /boot vfat defaults 0 2
PARTUUID=5e3da3da-02 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that
#//192.168.0.35/donnellyshare /mnt/Media/ cifs credentials=/home/pi/.smbcredentials 0 0
//NAS/donnellyshare /mnt/Media/ cifs credentials=/home/pi/.smbcredentials 0 0
#//NAS/donnellyshare /mnt/media/ cifs credentials=home/pi/.smbcredentials,vers=1.0

As you can see, I have tried a couple of different lines to mount the donnellyshare.

I can mount the donnellyshare via the sudo mount -a command with no errors.

Thank you in advance for your help.
Dave
Thanks,
Dave

dorian-ny
Posts: 66
Joined: Fri Nov 01, 2019 11:29 pm

Re: How do I mount NAS Network Shares

Sat Nov 09, 2019 12:35 am

My guess is that mount runs before network is up thus it is not accessible

try placing the follwoing script in /etc/init.d/mount-samba

#! /bin/sh

### BEGIN INIT INFO
# Required-Start: $local_fs $syslog $remote_fs dbus
# Default-Start: 3 4 5
# Default-Stop:
# Short-Description: mount smb shares
# Description: Mount network shares
### END INIT INFO

. /lib/lsb/init-functions

[ -f /etc/default/rcS ] && . /etc/default/rcS
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PROGRAM=/bin/mount

test -x $PROGRAM || exit 0


case "$1" in
start)
/bin/mount -a
log_action_end_msg 0
;;
stop)
;;
force-reload|restart)
$0 start
;;

Then execute
sudo chmod +x /etc/init.d/mount-samba
sudo systemctl enable mount-samba
Last edited by dorian-ny on Sat Nov 09, 2019 3:01 am, edited 1 time in total.

dorian-ny
Posts: 66
Joined: Fri Nov 01, 2019 11:29 pm

Re: How do I mount NAS Network Shares

Sat Nov 09, 2019 12:47 am

actually never mind the init.d script since the new raspian uses systemd might as well use it
write to /lib/systemd/system/mount-network-shares.service

[Unit]
Description=mount network shares
After=systemd-networkd-wait-online.service
Requires=systemd-networkd-wait-online.service

[Service]
Type=simple

User=root
WorkingDirectory=/home/pi/

ExecStart=/bin/mount -a


[Install]
WantedBy=multi-user.target

Then execute
sudo sudo systemctl daemon-reload
sudo systemctl enable mount-network-shares
Last edited by dorian-ny on Sat Nov 09, 2019 3:34 pm, edited 2 times in total.

Donnelly
Posts: 129
Joined: Wed Aug 21, 2019 10:54 pm

Re: How do I mount NAS Network Shares

Sat Nov 09, 2019 2:40 am

dorian-ny,
Completed your instructions:

write to /lib/systemd/system/mount-network-shares

[Unit]
Description=mount network shares
After=network.target

[Service]
Type=simple

User=root
WorkingDirectory=/home/pi/

ExecStart=/sbin/mount -a


[Install]
WantedBy=multi-user.target

Then execute
sudo chmod +x /lib/systemd/system/mount-network-shares
sudo sudo systemctl daemon-reload
sudo systemctl enable mount-network-shares

Results:
Command: sudo chmod +x /lib/systemd/system/mount-network-shares
No Issues or errors.

Command: sudo sudo systemctl daemon-reload
No issues or errors.

Command: sudo systemctl enable mount-network-shares
msg returned: Failed to enable unit: Unit file mount-network-shares.service does not exist.

I verified the file "mount-network-shares" does exist in the directory /lib/systemd/system/.
I also double checked the instructions entered.

Should I have restarted the RPi4 prior this effort? Such that the share was not mounted?

Next steps?
Thanks !
Dave
Thanks,
Dave

dorian-ny
Posts: 66
Joined: Fri Nov 01, 2019 11:29 pm

Re: How do I mount NAS Network Shares

Sat Nov 09, 2019 2:58 am

My fault apparently the file must be named /lib/systemd/system/mount-network-shares.service
I also made a careless mistake in the script, mount is in /bin not in /sbin
to fix my blunders
sudo mv /lib/systemd/system/mount-network-shares /lib/systemd/system/mount-network-shares.service
sudo sed -i 's/sbin/bin/g' /lib/systemd/system/mount-network-shares.service
sudo systemctl daemon-reload
sudo systemctl enable mount-network-shares
Last edited by dorian-ny on Sat Nov 09, 2019 3:43 am, edited 1 time in total.

Donnelly
Posts: 129
Joined: Wed Aug 21, 2019 10:54 pm

Re: How do I mount NAS Network Shares

Sat Nov 09, 2019 3:17 am

dorian-ny,
Followed all directions.

Results:
Command: sudo mv /lib/systemd/system/mount-network-shares /lib/systemd/system/mount-network-shares.service
No issues or errors

Command: sudo sed -i 's/sbin/bin/g' /lib/systemd/system/mount-network-shares.service
No issues or errors

Command: sudo systemctl daemon-reload
No issues or errors

Command: sudo enable mount-network-shares
Results: sudo: enable: command not found

Verified /lib/systemd/system/mount-network-shares.service was present.
Opened file in nano, file contents are correct.

Next steps?
Thanks,
Dave
Thanks,
Dave

dorian-ny
Posts: 66
Joined: Fri Nov 01, 2019 11:29 pm

Re: How do I mount NAS Network Shares

Sat Nov 09, 2019 3:22 am

did it again
sudo systemctl enable mount-network-shares

Donnelly
Posts: 129
Joined: Wed Aug 21, 2019 10:54 pm

Re: How do I mount NAS Network Shares

Sat Nov 09, 2019 4:02 am

dorian-ny,
Ah - ha !

Did dit again...
results:

Created symlink /etc/systemd/system/multi-user.target.wants/mount-network-shares.service - /lib/systemd/system/mount-network-shares.service.

now....?
Thanks,
Dave
Thanks,
Dave

Donnelly
Posts: 129
Joined: Wed Aug 21, 2019 10:54 pm

Re: How do I mount NAS Network Shares

Sat Nov 09, 2019 4:03 am

dorian-ny,

So now - I should reboot and the NAS share should auto mount? Correct?
Thanks,
Dave
Thanks,
Dave

Return to “Networking and servers”