DaedTech

Stories about Software

By

Create a Windows Share on Your Raspberry Pi

If I had to guess at this blog’s readership demographic, I’d imagine that the majority of readers work mainly in the .NET space and within the Microsoft technology ecosystem in general. My background is a bit more eclectic, and, before starting with C# and WPF full time in 2010, I spent a lot of years working with C++ and Java in Linux. As such, working with a Raspberry Pi is sort of like coming home in a way, and I thought I’d offer up some Linux goodness for any of you who are mainly .NET but interested in the Pi.

One thing that you’ve probably noticed is that working with files on the Pi is a bit of a hassle. Perhaps you use FTP and something like Filezilla to send files back and forth, or maybe you’ve gotten comfortable enough with the git command line in Linux to do things that way. But wouldn’t it be handy if you could simply navigate to the Pi’s files the way you would a shared drive in the Windows world? Well, good news — that’s what Samba is for. It allows your Linux machines to “speak Windows” when it comes to file shares.

Here’s how to get it going on your Pi. This assumes that you’ve setup SSH already.

  1. SSH into your Raspberry Pi and type “sudo apt-get install samba” which will install samba.
  2. Type “y” and hit enter when the “are you sure” prompt comes up telling you how much disk space this will take.
  3. Next do a “sudo apt-get install samba-common-bin” to install a series of utilities and add-ons to the basic Samba offering that are going to make working with it way easier as you use it.
  4. Now, type “sudo nano /etc/samba/smb.conf” to edit, with elevated permissions, the newly installed samba configuration file.
  5. If you go navigate to your pi’s IP address (start, run, “\\piip”), you’ll see that it comes up but contains no folders. That’s because samba is running but you haven’t yet configured a share.
  6. Navigate to the line in the samba configuration file with the heading “[homes]” (line 244 at the time of this writing), and then find the setting underneath that says “browseable = no”. This configuration says that the home directories on the pi are not accessible. Change it to yes, save the config file, and observe that refreshing your file explorer window now shows a folder: “homes.” Cool! But don’t click on it because that won’t work yet.
  7. Now, go back and change that setting back under homes because we’re going to set up a share a different way for the Pi. I just wanted to show you how this worked. Instead of tweaking one that they provide by default, we’re going to create our own.
  8. Add the following to your smb.conf file, somewhere near the [homes] share.PiSamba
  9. Here’s what this sets up. The name of the share is going to be “pi” and we’re specifying that it can be read, written, browsed. We’re also saying that guest is okay (anyone on the network can access it) and that anyone on the network can create files and directories. Just so you know, this is an extremely permissive share that would probably give your IT/security guy a coronary.
  10. Now, go refresh your explorer window on your Windows machine, and viola!
    SambaWindows
  11. If some of the changes you make to samba don’t seem to go through, you can always do “sudo service samba restart” to stop and restart samba to make sure your configuration changes take effect. That shouldn’t have been strictly necessary for this tutorial, but it’s handy to know and always a good first troubleshooting step if changes don’t seem to go through.

And that’s it. You can now edit files on your Pi to your heart’s content from within Windows as well as drag-and-drop files to/from your Pi, just as you would with any Windows network share. Happy Pi-ing!

By the way, if you liked this post and you're new here, check out this page as a good place to start for more content that you might enjoy.
12 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Surreywinter
Surreywinter
10 years ago

Hi – I’m getting “you need permission to perform this action” error from windows when I try to copy to a Pi folder. Navigation & read works – just no “write”. Any ideas?

Erik Dietrich
10 years ago
Reply to  Surreywinter

It might be a question of the Pi’s Linux directory permissions. If you go on the Pi to the directory in question and then do “chmod 777” you can see if you’re able to write. If so, it was a Linux permissions issue.

Surreywinter
Surreywinter
10 years ago
Reply to  Erik Dietrich

Thanks – sorted.

sudo chmod -R 777 /home/pi/

Erik Dietrich
10 years ago
Reply to  Surreywinter

Glad if it helped. Not bad for a blind shot at the problem 😀

Dustin Wood
Dustin Wood
9 years ago
Reply to  Erik Dietrich

Heh. And I’ve spent the past couple hours trying to figure out this same issue myself. A couple tutorials, and nothing was working. This comment, and Boom! Fixed. Thanks!

Erik Dietrich
9 years ago
Reply to  Dustin Wood

Happy to hear it! I’ve been in your position so, so many times that I know what a relief that is (though sometimes also infuriating)

MauriceLargeron
MauriceLargeron
10 years ago

tks for this tutorial..
strange enough i’ve got under win7 a popup windows asking for user and password..weird ?

Erik Dietrich
10 years ago

I think that’s normal the first time you access it. If you type in the login credentials for the pi (i.e. pi/raspberry), it should probably cache them in the Windows credential manager and you won’t have to do it again.

MauriceLargeron
MauriceLargeron
10 years ago
Reply to  Erik Dietrich

ah ok tks erik i’ll do it then….for the story, i used this way to retrieve files from the pi :http://schoolpiclub.wordpress.com/2014/04/08/transferring-files-from-raspberry-pi-to-a-computer-using-filezilla/ ..

Stevie Wonder
Stevie Wonder
9 years ago

Hey Erik, thanks for the tutorial. I’m 95% there, but getting hung up at the last step- hope you can help. Installed samba, edited samba.conf to share a directory off my home. On win8.1 box, open \rpi-ip, I see my share listed along with a printer I previously shared. When I double-click to open the shared folder, I’m asked for credentials. I’ve tried all kinds of permutations of username/password/domain name, nothing is working (keep getting bounced back to “supply credentials” dialog, sometimes immediately sometimes long delay). Tried various “sudo chmod -R 0777 homepisharename” incantations, as well as various “domainuser ”… Read more »

Stevie Wonder
Stevie Wonder
9 years ago
Reply to  Stevie Wonder

Never mind- got it! My smb.conf was all messed up- I stuck my share configuration right in the middle of the [home] config slot. Then a few remaining issues with permissions on the linux side (added create mask = 0777 and directory mask = 0777 to smb.conf, and also “chmod 0777 sharedir” on the shared directory).

Thanks again for the tute.

Erik Dietrich
9 years ago
Reply to  Stevie Wonder

No worries, and glad you got it sorted. I was sort of off the grid for the holiday weekend, but it’s also been a while since I played with this, so I’m not sure exactly how much help I would have been 🙂