Friday 29 November 2013

Raspberry Pi Windows Shared folders, Samba/CIFS client,

Another post that I has lying around in scratch book status for ages, so time to finalise it. This post is based on version 3.6.11+, most of my Raspi is unchanged an very stock standard, so I would assume mounting your drive should work using my instructions below.

SAMBA was originally SMB Server - but the name had to be changed due to SMB Server being an actual product. SMB was the predecessor to CIFS. SMB "server message block" and CIFS "common internet file system" are protocols. Samba implements CIFS network protocol. This is what allows Samba to communicate with (newer) MS Windows systems. Typically you will see it referred to SMB/CIFS. However, CIFS is the extension of the SMB protocol so if someone is sharing out SMB via Samba to a legacy system still using NetBIOS it will typically connect to the Samba server via port 137, 138, 139 and CIFS is strictly port 445 (You will see this is you spin up wireshark on a test machine). 

First of all, verify if the cifs module is installed

pi@raspberrypi ~ $ dpkg-query -S cifs-utils
cifs-utils: /usr/share/doc/cifs-utils
cifs-utils: /usr/share/doc/cifs-utils/changelog.gz
cifs-utils: /usr/share/doc/cifs-utils/NEWS.Debian.gz
cifs-utils: /usr/share/doc/cifs-utils/README
cifs-utils: /usr/share/doc/cifs-utils/changelog.Debian.gz
cifs-utils: /usr/share/doc/cifs-utils/copyright


To verify if the samba software has been installed,  by issuing:

pi@raspberrypi ~ $ dpkg -l | grep samba-common
ii  samba-common      2:3.6.6-6+deb7u1      all common files used by both the Samba server and client

Or issue   dpkg -p samba-common  to check its dependencies. 


First all, you will create a mount point, this is nothing more then a directory that will contain the contents of the shared drive or folder once it is mounted.

Do this by creating a directory, this cold be in your home folder or where ever you want, I have chose to use /mnt/ to keep things consistent:



mkdir /mnt/TPLINK_NAS1

Now mount the drive to the mount point for example:


mount -t cifs -o sec=none //10.19.19.102/volume1/cams/front1 /mnt/TPLINK_NAS1


As you will notice I have used the sec=none switch, this because there is an issue with Raspian, as of version 3.10.19, that causes problems when using username and password. Or so is the consensus on the raspi.org forum:

Source:
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=60699&p=459637#p459637

What this does is actually explicitly link the /volume1/cams/front1 directory to mnt/TPLINK_NAS, which means everythging that gets dumped into the mount point, essentially gets dumped onto the share. Very much like mapping shares in Windows, but better.


Permanent shares at start up. Well of course the above mount command lasts till reboot, or otherwise explicitly unmounted. In order to mound a share to a mount point at start up. the place to do this is:


/etc/fstab

I have edited fstab similar to the mount command, as per below

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p5  /boot           vfat    defaults          0       2
/dev/mmcblk0p6  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, so no using swapon|off from here on, use  dphys-swapfile swap[on|off]  for that
//10.19.19.102/volume1/cams/front1 /mnt/TPLINK_NAS1 cifs guest,users,uid=1000,auto,_netdev 0 0

To verify If your mount is functioning, issue:

cat /proc/mounts


Goodluck

Sources:

Full book on Samba:

http://www.samba.org/samba/docs/using_samba/ch00.html



https://wiki.samba.org/index.php/Mounting_samba_shares_from_a_unix_client



http://rasspberrypi.wordpress.com/2012/09/04/mounting-and-automounting-windows-shares-on-raspberry-pi/



No comments:

Post a Comment