Share a folder with a Windows computer from a Raspberry Pi

Sharing files over the network is incredibly handy, when I was writing code examples to publish on this site it was useful to run them on the Raspberry PI, copy them to a folder which could be accessed on my Windows 7 PC.

Install and configure required software

To share network folders to a Windows computer we need to install some special software on the Raspberry Pi. The software providing the secret sauce this time is called Samba. The Samba software package implements the SMB protocol and provides support for the Windows naming service (WINS) and for joining a Windows Workgroup.

Installing the software is easy – login to your Raspberry Pi and run the following:

[codesyntax lang=”bash”]

sudo apt-get install samba samba-common-bin

[/codesyntax]
After installation configure the software by opening the file /etc/samba/smb.conf using the command:
[codesyntax lang=”bash”]

sudo nano /etc/samba/smb.conf

[/codesyntax]

Read through the file and make sure you have the following parameters set, on my one win support was no and commented out:

[codesyntax lang=”bash”]

workgroup = WORKGROUP
wins support = yes

[/codesyntax]

You can use anything as your workgroup name as long as it is alphanumerical and matches the workgroup you would like to join. The default workgroup in Windows 7 is WORKGROUP.

Setup folder to share

Next step is to create the folder you would like to share. To create a folder called “myshare” in your home directory do the following:

[codesyntax lang=”bash”]

mkdir ~/myshare

[/codesyntax]

With the folder created we can now tell the Samba software to share it on the network. Open the file /etc/samba/smb.conf using the command:

[codesyntax lang=”bash”]

sudo nano /etc/samba/smb.conf

[/codesyntax]

Scroll to the bottom and add the following:

[codesyntax lang=”bash”]

[PiShare]
comment=Raspberry Pi Share
path=/home/pi/myshare
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no

[/codesyntax]

Notice how we tell Samba that public access is not allowed via “public=no” – this means that anyone wanting to access the shared folder must login with a valid user.

In this case the valid user is the user called “pi”. To let Samba know that “pi” is a network user run the command:
sudo smbpasswd -a pi
And enter pi’s password twice (default: raspberry).

At this point we can now login to the share from our Windows computer – use Domain: raspberrypi, User: pi and Password: raspberry

If you do not to have to log in all of the time you can always make the share publicly available by changing the config file to say:
public=yes

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :