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.

raspbian-nasBefore 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