wranzzon
Posts: 25
Joined: Mon Feb 20, 2012 7:51 pm

cant autoconnect to cifs-share

Fri Oct 19, 2012 4:26 pm

Hello

i´ve mounted my networkdrive to /mnt/nas
im trying to add a line in /etc/fstab So that it connects to the networkdrive automatic, but I cant get it to work. I have tried like 15 diffrent lines that I´ve found on the net but none are working.

The line im using to connect to the networkdrive is:

mount -t cifs "//192.168.1.77/GoFlex Home Personal/" -o username=wranzzon,password=****** /mnt/nas -o iocharset=utf8,file_mode=0777,dir_mode=0777

I need both read and writing-permissions. If that has anything to do with anything

User avatar
LetHopeItsSnowing
Posts: 357
Joined: Sat May 26, 2012 6:40 am
Location: UK
Contact: Website

Re: cant autoconnect to cifs-share

Fri Oct 19, 2012 5:38 pm

Can you post the config you have in fstab?

First thoughts are to try without spaces in the share name.

If you want a working example take,a look at http://www.stuffaboutcode.com/2012/05/r ... share.html
"am I getting slower, or is stuff more complicated; either way I now have to write it down - stuffaboutcode.com"

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2810
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: cant autoconnect to cifs-share

Fri Oct 19, 2012 7:26 pm

This works on my goflex...

Code: Select all

sudo mount -t cifs '//192.168.XXX.XXX/GoFlex Home Public' /home/pi/goflex/public -o username=blahblah,password=blahblah,iocharset=utf8,file_mode=0777,dir_mode=0777
...but I run it from a bash script with a separate command for each of public, backup and personal.
You could put the command(s) in a bash script and add that to /etc/rc.local

Or you could just put the command in /etc/rc.local

Other people use cron to attach on startup.

Or you could use fstab, but it seems quite finicky.
Alex Eames RasPi.TV, RasP.iO

wranzzon
Posts: 25
Joined: Mon Feb 20, 2012 7:51 pm

Re: cant autoconnect to cifs-share

Fri Oct 19, 2012 8:42 pm

I have tried the link that LetHopeItsSnowing showed me, But without success. .

alexeames:

Im a total beginner at this, is it easy to make a script?

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2810
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: cant autoconnect to cifs-share

Fri Oct 19, 2012 10:25 pm

OK. It isn't difficult, but there are a few steps.
I'll cook you up some instructions tomorrow :D
Alex Eames RasPi.TV, RasP.iO

wranzzon
Posts: 25
Joined: Mon Feb 20, 2012 7:51 pm

Re: cant autoconnect to cifs-share

Sat Oct 20, 2012 7:47 am

Nice, thx alot.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2810
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: cant autoconnect to cifs-share

Sat Oct 20, 2012 6:22 pm

from your command line, type

Code: Select all

cd ~
that puts you in your home directory

Code: Select all

nano goflex.sh
opens a file for editing and calls it goflex.sh

then you need to type your command, changing the 192.......XXX to the Goflex IP address. change username and password to yours, and you might need to change Home Public to whatever you want to connect to.

Code: Select all

sudo mount -t cifs '//192.168.XXX.XXX/GoFlex Home Public' /home/pi/goflex/public -o username=blahblah,password=blahblah,iocharset=utf8,file_mode=0777,dir_mode=0777
then...

Code: Select all

CTRL+O
save

Code: Select all

CTRL+X
exit

you might notice I mounted it as a subdirectory of /home/pi this is to ensure you will have full read/write access from user pi. But before we do anything else, we need to create that directory and give it the right permissions...

Code: Select all

mkdir goflex
make directory called goflex

Code: Select all

sudo chmod 777 goflex
become super-user just for this command and change directory permissions to full read/write/execute for all users

Now we need to make the script we wrote executable so we can run it...

Code: Select all

sudo chmod +x goflex.sh
Now, a drumroll and we'll try to run it...

Code: Select all

./goflex.sh
(the reason for the ./ is because we are in the same directory as the file we want to run. Anywhere else we would type the full path to the file to run it.)

If you see the normal prompt and no error message, it worked. Now you can go there...

Code: Select all

cd goflex
ls -l
and you should see a list of your directories/files

If it didn't work, you'll get an error message and most likely something in the script is wrong. Check check, double check.
Alex Eames RasPi.TV, RasP.iO

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2810
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: cant autoconnect to cifs-share

Sat Oct 20, 2012 7:24 pm

between CTRL+O and CTRL+X you need to press Enter
Alex Eames RasPi.TV, RasP.iO

wranzzon
Posts: 25
Joined: Mon Feb 20, 2012 7:51 pm

Re: cant autoconnect to cifs-share

Sun Oct 21, 2012 12:50 pm

Thx for a excellent description, the script works, but am i suppose to run the script everytime I restart the Pi? because now I have to do that, otherwise Everything I download will end up in the folder /home/pi/goflex on the Pi... Because thats not quite what I wanted. Or have I done something wrong?

itimpi
Posts: 1082
Joined: Sun Sep 25, 2011 11:44 am
Location: Potters Bar, United Kingdom
Contact: Website

Re: cant autoconnect to cifs-share

Sun Oct 21, 2012 1:15 pm

I have found that you can use an entry in /etc/fstab of the form

Code: Select all

//network_address/sharename  /media/mountpoint cifs defaults,username=ddd,password=jjj,uid=1000,gid=100,rw  0 0
(all on one line) then if the it is present a network drive is automeounted during boot.

wranzzon
Posts: 25
Joined: Mon Feb 20, 2012 7:51 pm

Re: cant autoconnect to cifs-share

Sun Oct 21, 2012 2:11 pm

Tried this one too now, And still no luck. I dont understand what can be the problem...

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2810
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: cant autoconnect to cifs-share

Sun Oct 21, 2012 3:54 pm

wranzzon wrote:Thx for a excellent description, the script works, but am i suppose to run the script everytime I restart the Pi? because now I have to do that, otherwise Everything I download will end up in the folder /home/pi/goflex on the Pi... Because thats not quite what I wanted. Or have I done something wrong?
No, you've only done part one. I haven't given you part 2 yet. I wanted to see if you could get part 1 working first.

Part 2 is as follows...

we need to modify the script we wrote slightly.

Code: Select all

cd ~

Code: Select all

nano goflex.sh
then add this right at the top

Code: Select all

#!/bin/bash
this will enable it to run when called from another script

Code: Select all

CTRL+O
Enter
CTRL-X
Then we add a line to this file...

Code: Select all

sudo nano /etc/rc.local
this will open a file that contains stuff that runs at boot. This one won't open unless you use sudo as it's a system file.

Go to the bottom just above the line which says "exit 0". There you should type...

Code: Select all

/home/pi/goflex.sh
Then save and exit as usual

Code: Select all

CTRL+O
Enter
CTRL-X
And then it should work whenever you boot up.

Code: Select all

sudo reboot
to give it a try
Alex Eames RasPi.TV, RasP.iO

wranzzon
Posts: 25
Joined: Mon Feb 20, 2012 7:51 pm

Re: cant autoconnect to cifs-share

Sun Oct 21, 2012 5:14 pm

No way, it works perfectly. thank you for all your help. I appreciate it alot. Its people like you who makes the world a better place

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2810
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: cant autoconnect to cifs-share

Sun Oct 21, 2012 6:06 pm

wranzzon wrote:No way, it works perfectly. thank you for all your help. I appreciate it alot. Its people like you who makes the world a better place
And it's people like you saying thanks, and being encouraged to press on with your computing, that makes helping people out a worthwhile activity. I'm really chuffed it works for you. :D

Just a quick note to add. If you want to mount more than one of the folders, public, private and backup you need to make a separate directory for each as we did in part 1 above (can be a sub-directory of goflex). This may be obvious, but I thought I'd spell it out anyway. :)
Alex Eames RasPi.TV, RasP.iO

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2810
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: cant autoconnect to cifs-share

Mon Oct 22, 2012 9:55 am

Now we've got you up and running I thought I'd blog the full procedure. I've actually added a bit to make it slightly more complete (regarding directories) and clearer for new users. I've also tested it fully. The result is here...

http://raspi.tv/2012/how-to-connect-a-g ... spberry-pi
Alex Eames RasPi.TV, RasP.iO

wranzzon
Posts: 25
Joined: Mon Feb 20, 2012 7:51 pm

Re: cant autoconnect to cifs-share

Tue Oct 23, 2012 8:53 am

Yeah it looks great. Hopefully other people will find this useful

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2810
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: cant autoconnect to cifs-share

Tue Oct 23, 2012 9:42 am

wranzzon wrote:Yeah it looks great. Hopefully other people will find this useful
Must be more than just you and me with a Goflex and a RasPi. :lol:
Alex Eames RasPi.TV, RasP.iO

wranzzon
Posts: 25
Joined: Mon Feb 20, 2012 7:51 pm

Re: cant autoconnect to cifs-share

Wed Oct 24, 2012 8:04 am

Yeah totally

Packjed
Posts: 1
Joined: Sun Apr 06, 2014 9:29 pm

Re: cant autoconnect to cifs-share

Sun Apr 06, 2014 9:36 pm

I realize this post is old, but I am trying to follow these instruction (for which I am grateful), and running into:

Mount error(13)

Any ideas?

Update:
I was using the extended username that you need to ssh in to the GoFlex, instead of the abbreviated one... It works now!

User avatar
DougieLawson
Posts: 33805
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: cant autoconnect to cifs-share

Mon Apr 07, 2014 1:49 pm

Packjed wrote: Mount error(13)
It's a security/permissions error. Look at resetting your password on the server with smbpasswd. Check that you're passing the right userid/password (and if needed domain) on the mount command (or in your credentials file).
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

m3lvy
Posts: 1
Joined: Wed Mar 09, 2016 1:49 am

Re: cant autoconnect to cifs-share

Wed Mar 09, 2016 1:55 am

Hi,

Apologies for resurrecting this old thread but I can't get this to work on boot. It's fine when I run the script manually but it just doesn't seem to work when I boot up the Pi (part 2). I'm missing something between editing the goflex.sh script and /etc/rc.local.

Thanks!

Return to “Beginners”

Who is online

Users browsing this forum: Baidu [Spider] and 17 guests