walmathanyou
Posts: 13
Joined: Wed Jun 03, 2020 2:09 pm

[SOLVED] Auto mounting smb share

Mon Jun 08, 2020 3:01 pm

I can manage to mound my PC share in terminal using:

Code: Select all

sudo mount -t cifs //PC/Share /mnt/share -o username=username,password=password

I add the following to /etc/fstab

Code: Select all

//PC/Share /mnt/share cifs username=username,password=password 0 0
After a reboot it doesn't seem to mount.
I have tried with my PC IP instead of name to no avail.

Suggetions?
Last edited by walmathanyou on Tue Jun 09, 2020 10:44 am, edited 1 time in total.

walmathanyou
Posts: 13
Joined: Wed Jun 03, 2020 2:09 pm

Re: Auto mounting smb share

Mon Jun 08, 2020 3:05 pm

After rebooting i enter:

Code: Select all

sudo mount -a
Then it mounts, but not automatically.

jacksona69
Posts: 4
Joined: Sun May 03, 2020 5:52 am

Re: Auto mounting smb share

Mon Jun 08, 2020 3:12 pm

Go into Raspi-Config, and set it to wait for network on boot. What's happening is that it's trying to mount before the network is connected.

HTH.

User avatar
thagrol
Posts: 7189
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Auto mounting smb share

Mon Jun 08, 2020 5:42 pm

Try changing your fstab entry to

Code: Select all

//PC/Share /mnt/share cifs _netdev,username=username,password=password 0 0
That should delay the mout until after the network is up.

You should also consider using the "noauto" and "x-systemd.automount" options. With those the share won't be mounted during boot (or on mount -a) but on first attempt to access it.

Oh, and expect permissions issues if you want to write to the share. Default permissions only allow writing by the owner who, unless specified in the mount options will be root when mounting via fstab.

See the output of

Code: Select all

man mount.cifs
for more info.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

walmathanyou
Posts: 13
Joined: Wed Jun 03, 2020 2:09 pm

Re: Auto mounting smb share

Tue Jun 09, 2020 9:29 am

Thanks, I am not worried about writing to the share, just want to stream media.

I think it could be a permissions issue ???
After a reboot i can see it on the GUI under the Filesystem but when I try and open it, it asks for credentials.
I have tried making a credentials file but still no luck.

walmathanyou
Posts: 13
Joined: Wed Jun 03, 2020 2:09 pm

Re: Auto mounting smb share

Tue Jun 09, 2020 10:44 am

Ok I have a working solution :D

Code: Select all

//192.168.2.7/Videos /mnt/Videos cifs _netdev,credentials=/home/pi/.andycreds,uid=pi,gid=pi,x-systemd.automount 0 0

User avatar
DMike92
Posts: 28
Joined: Mon Dec 29, 2014 12:52 am
Location: France

Re: [SOLVED] Auto mounting smb share

Sun Dec 27, 2020 5:19 pm

Hi,
Was your password containing funny chars and is more accepted in a credential file?
Le savoir ne vaut que quand il est partagé (c'est pas de moi mais j'adhère).

Return to “Beginners”