This guide assumes you already have Raspbian OS installed in your Raspberry Pi with LAN setting properly established. My Raspbian image file is dated 9 Feb 2013. Different version of Raspbian might produce different behavior.
Before installing new application or service in Raspbian, make sure to always type this into terminal :
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
If you’re installation is not the latest version, it might take a while as Raspbian will download the latest files from Internet.
Now, open terminal again and type:
cd /home/pi
mkdir myNAS (change “myNAS” with the name of your NAS server)
cd myNAS
mkdir myShare (change “myShare” with the name of your NAS share)
Next, type this to edit fstab file:
sudo nano /etc/fstab
Add this line at the bottom:
//myNAS/myShare /home/pi/myNAS/myShare cifs username=your_username,password=your_password,uid=pi,gid=debian-transmission 0 0
(naturally, change “myNAS”, “myShare”, your_username and your_password with appropriate setting according to your NAS server, change “pi” to your Raspbian username)
For better security, you might want to avoid writing your username and password in fstab file. There’s a workaround for this by creating a separate file to contain your credentials. (credit to Daniel Windura for pointing up this issue)
//myNAS/myShare /home/pi/myNAS/myShare cifs credentials=/etc/mycredentialfile,uid=pi,gid=debian-transmission 0 0
Don’t forget to make the credential file (you can change “mycredentialfile” to whatever you like):
sudo nano /etc/mycredentialfile
Type:
username=your_username
password=your_password
Then save the file.
sudo chmod 600 /etc/smbcredentials (to make only “root” can read and write to this file)
Done! Simple and easy.
Now all we need to do is reboot the Raspberry Pi and test it.
sudo reboot
Also read: my other posts about Raspberry Pi
At the startup log, I get the following error:
mounting local filesystems mounting point 0 does not exist
Any ideas?
I can’t be really sure without actually checking, but I would guess it has something to do with your network connection. RPi (using cable or LAN) needs to be configured properly so it can connect to your home network and can detect the NAS. And bear in mind that the settings (IP addresses etc) for cable connection and Wifi in RPi are two separate settings.
Thank you for the reply.
Both my RPi and the NAS have a static IP adress set up, and I can connect to the pi via SSH/VNC from a computer of the same network, so I’d say my network won’t be the problem…
If I write :
//myNAS/myShare /home/pi/myNAS/myShare cifs username=your_username,password=your_password,workgroup=your_workgroup,users,auto,user_xattr 0 0
in the fstab file, it actually asks me for a password (I suppose the NAS’ ?), but after that, it says:
mount error(13): permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mount: mount point 0 does not exist
Any help?
Again, I can never be sure about the problem since I can’t check the devices directly, but here’s my guess:
Your line is a bit different from my line stated in the article, you only have connection to your NAS, the part connecting the right to your current RPi id is not there.
This clause : uid=pi,gid=debian-transmission 0 0
is actually to redirect the rights you obtain from connecting to NAS using NAS’ username and password to your RPi username and group (I assume the default username “pi” and group id “debian-transmission”)
If you omit this part, you will only “connect” to the NAS, but failed to give yourself the right to use it (pi user).
Maybe this is the reason RPi asked you for password. Maybe. I can only guess since I can’t actually inspect the device and your network.
Hi, I was wondering whats the significance of gid pointing at transmission and do you know what other options would be typical for that parameter?
Cheers for the post!
el
Pointing gid will give our RPi group the right to fully-access (add, edit, delete) files in NAS. In my case, without gid pointing, I can see the NAS appear in my RPi, but I can’t do anything with my files there.
Hi,
I was able to follow your tutorial, but what if you dont have a user and password on your NAS?
What does the script look like?
Thanks in advanced
if you’re using separate credential file, you can simply leave out the part that refers to the “external” credential file; if you’re using my normal syntax, just remove the part of username and password, I think it should work
Didn’t work for me so I used my local pi username and password and all is good. Probably not the perfect solution but its working and that will do for now!
Some of my friends also told me different behavior in this issue. I guess it depends on the system in your NAS.