Transferring files from a Raspberry Pi to Windows using SMB.

I wanted to be able to move files from the memory stick on the Raspberry Pi in my Weather Balloon package, to the PC controlling it. Using WiFi, when in range, and setting up the Raspberry Pi as a SMB Network drive.

I use file sharing using SMB windows drives with PC’s, iPad and Android but did not realise this would also be possible with a Raspberry Pi. Wikipedia describes SMB Network Drives as:

‘Server Message Block (SMB), operates as an application-layer network protocol mainly used for providing shared access to files, printers, and serial ports and miscellaneous communications between nodes on a network. Most usage of SMB involves computers running Microsoft Windows, where it was known as “Microsoft Windows Network” before the subsequent introduction of Active Directory.’

The result is that you can copy files from one device to another over a network as long as the devices appear as SMB drives. SAMBA is used to turn the Raspberry Pi into an SMB drive and is installed as follows.

Install Samba

sudo apt-get install samba samba-common-bin

Samba contains the SMB protocol, support for the Windows naming service (WINS), and support for joining Windows workgroups. Samba-common-bin contains a tool that you’ll need to register users with Samba.

Configure Samba

sudo nano /etc/samba/smb.conf

Search for the workgroup line (normally at the top) and if necessary set it to match your workgroup, although I left it unchanged.

Use <Ctrl + W> to find the wins support, if there is a # at the start of the line remove it to stop it being commented out and then ensure it is set to “yes”, so you should have:

workgroup = your_workgroup_name (if you want to use this, otherwise dont add this)
wins support = yes (this is necessary)

Now at the very bottom of the code add a section which contains the settings for the share:

[pihome]
comment= Pi Home
path=/home/pi
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no

Change path as required “path=/” is fine if you want access to the entire drive. For example the USB memory stick is found at /Media/USB Memory Stick (where USB Memory Stick is the name of your Stick)

If you want to permit read only access change writeable to “No”

Use CTRL+X to save and exit.

Finally add the pi user by typing this command and entering the pi’s password twice (the default user name is pi and password is raspberry):

sudo smbpasswd -a pi

That’s it. If you select “Network” in windows explorer device “RASPBERRYPI” should be found (it may take a minute or two to appear). In it the “pihome” folder will be the folder you’ve shared.

Restarting Samba

Samba starts when the Raspberry Pi starts up, but should you need to restart it then use the following.


sudo /etc/init.d/samba restart

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s