Raspberry Pi Home Server: Part 7, Sharing Files With Samba

Article Obsolete

A new version of this series has been published. Please refer to the new index for updated articles and ordering. This article is kept for historical reference, but should be considered out of date.

Note: This article is part of a series. See the Index for more information.

Self-promotion: I’ve recorded this series as a screencast for Pluralsight:
If you have a Pluralsight subscription, please consider watching it. Thanks!

Updates: Everything in this post works just fine under the Jessie release of Raspbian, so there are no changes to report at this time.

Now that the Raspberry Pi has the space to hold your stuff, it’s about time it started doing something useful around the house. Its first task will be to share files from the hard drive. In the previous post we added a hard drive with two partitions, one ext4 partition for the operating system, and one NTFS partition to hold data.


  • A Raspberry Pi
  • A mounted, USB hard drive
    Mine is the second hard drive partition, mounted at /mnt/data

Install Samba

The “Samba” package creates network file shares in a way that Mac and Windows computers on the network will understand. Install Samba as follows:

sudo apt-get install samba samba-common-bin

Set up shares

Just for fun, we’ll use Webmin to do this part. Get to a browser on your primary computer (or the Pi, if you like waiting), and navigate to the Raspberry Pi’s IP address, port 10000 (e.g.

Webmin has a Samba administration module, which should currently be listed under the “Un-used Modules” section because Samba wasn’t installed before. Since you’ve just installed Samba, it would be nice if this module weren’t hidden like this. Click “Refresh Modules” near the bottom of Webmin’s left-hand menu, and Webmin will go through its inventory, and figure out which modules can actually be used. This can take a little while, so be patient.

When it is finished, the “Samba Windows File Sharing” module should have moved to the “Servers” section at the top.

Click on the “Samba Windows File Sharing” module, and then on the “Windows Networking” icon under “Global Configuration”. Change “Workgroup” to match your home network if it is different (it’s probably just “WORKGROUP”, though, unless you specifically changed it). Select the “Be a WINS server” radio button on the second row.


Click “Save” to save the settings and return to the main Samba page.

Click on the “Create a new file share” link near the top of the page. Give the new share a name. I called mine “Data” to avoid confusion, and type “/mnt/data” (or whatever you called your mount point) in the “Directory to share” textbox. Your screen should look like this:


Click “Create” to create the share, and you will be taken back to the main Samba page. Your new share should now appear in the list. Click on it to go to the “Edit File Share” page. From here, click the “Security and Access Control” icon.

Set “Writeable” and “Guest Access” to “Yes”.


Click “Save” to save your settings and return to the “Edit File Share” form.

Click the “Return to share list” link at the bottom of the page to return to the main Samba page.

Click on the “Restart Samba Servers” button near the bottom of the page. You should now be able to view the share from other computers on your network.



This is a wide-open file share. Anyone on the local network can add, edit, or delete the files it contains. I am not a Linux security expert, and somewhere someone is screaming at me for doing it all wrong. I’m sorry, it’s nothing personal, but we’re talking about a home network, here. I’m more interested in having a place to put stuff than in controlling access to it.

You can certainly do that, of course, but the intricacies of Linux filesystem security are beyond the scope of this series.

Make some folders

Create some file folders in the Data share to hold your stuff, and copy it in. Music, Pictures, Videos, anything you want. For this server, I’ve created the following folder structure.

  • Documents
    • Music
    • Pictures
    • Videos
  • Downloads

You don’t have to use the same structure as me, of course, but this is the one I’ll be using in future posts, so you’ll need to adjust accordingly if you do something else.

Load it up

When it comes to copying the files in, you can save some time, and skip the network bottleneck by moving the external hard drive to the computer that currently has the data. Because the data partition was formatted as NTFS in the previous post, when you plug it in to your Windows or Mac computer, you’ll just see a drive called “Data”, or whatever you named it.

Remember to shut down the Raspberry Pi before removing the hard drive, of course. Just put it back when you’re done copying files, and start up the Raspberry Pi as usual.

What’s next?

In the next post, we’ll get a media server up and running so that you can stream music and movies all over your house from the hard drive share.

This entry was posted in Computers and Internet, Home Server, Raspberry Pi and tagged . Bookmark the permalink.

47 Responses to Raspberry Pi Home Server: Part 7, Sharing Files With Samba

  1. Pingback: Raspberry Pi Home Server: Index | MelGrubb.ToBlog()

  2. Pingback: Raspberry Pi Home Server: Part 6, Adding a hard drive | MelGrubb.ToBlog()

  3. Alex says:

    I appreciate all the hard work you have done in setting this up. I am having an issue that I can’t see my shared drive on my network, I followed inst and was doing great. I have minidlna showing up on shared network, but not my hard drive. Any suggestions would be greatly appreciated. I am a nb at home servers. Thanks in advance

    • Mel Grubb says:

      This is part of why I use webmin to set up the shares. In my experience, it sets up the permissions appropriately, or at least makes it easier for a Linux non-expert. Double check that your settings match the screenshots in the article, for starters. It should result in a wide-open read/white share, not something you’d want on a business network, but pretty much ideal for a home network.

  4. Have followed your excellent instructions for my new Pi-2. Got to this part, created the share, gave it permissions. Can see the share from my WIndows box.
    Tried to create a folder from the Windows box, get invalid permissions.
    Next step?
    (BTW, excellent series….I am hoping for more on your site!)

    • ..so I started poking around, and found that although the root user could create a folder (in the Pi terminal), the other user I created could not. Which led me to some googling, and I figured that the share I created in SMB (via Webmin) didn’t have the right permissions.
      So I changed the File Permission Options (after selecting the share) to 777 (was 755, which is the default value), saved it, restarted Samba.
      Then I went to Terminal, did a ‘cd /mnt/data’, then a ‘sudo chmod 0777 *’, then a ‘ls -la’ to verify that the ‘media’ folder (which I created in Terminal) had the 777 permissions.
      Then back to the Windows box, refreshed the file explorer screen, selected the ‘media’ folder (off of the root), and now able to create new folders.
      Huzzah for me! (an old PC geek, with ‘just-past-noob’ Linux skilz)
      Now on to the media server with your excellent guide!

    • Mel Grubb says:

      I’m glad you got it worked out. Is the drive you’re sharing formatted as ext4, or NTFS? In the series, I built mine using NTFS so that it can be attached directly to my laptop when I have some heavy lifting to do. This seems to be part of the magic that lets my shares work the way they do security-wise. If you use an ext4 drive, then you have to get your hands a little dirty to get things set up the same way. I should make up a Linux security crash course post at some point, and link to it from the hard drive article.

      • (Getting back to this project area….)
        The drive was set up as NTFS. The shared “Raspberry1” is /mnt/data . I can see the Raspberry1 folder on my windows box. I can copy (from the windows box) files to “Raspberry1”, and can see them with a ‘ls’ command on the terminal.

        If I shut down the Pi, then move the drive to my windows laptop, I can see the ‘data’ drive. I can copy files to that ‘data’ drive via the windows laptop connection. When I move the external drive back to the Pi, restart, log in, an ‘ls’ shows the small files I copied.

        When I copy a mpg file (about 5gb) from windows laptop to external drive (connected to laptop), then move the external drive back to the Pi, those large files are not shown with an ‘ls’ command at the terminal.

        Is there some setting in Samba that is not allowing large files to be stored?


  5. Tom says:

    I had to install Webmin. It wasn’t available. I am using latest Raspbian image, 2015-02-16-raspbian-wheezy

  6. mancony says:

    Any ideas how to do this using a mac rather than windows? I get permission errors when i try to create a new folder in the ‘Data’ folder with samba and after having a fiddle can’t seem to get properly connected.

    • Mel Grubb says:

      I’m afraid I don’t have a Mac to test with. Formatting the shared drive as NTFS was part of what dumbs down the security so that the share becomes public. You could look into opening up the security on the share manually through chmod. I didn’t get to experiment with the Pi at all this weekend, unfortunately. I might some evening this week, though. ________________________________

  7. timxjr1300 says:

    Have you got any suggestions for what to do with a USB HDD from anther NAS device. I’m trying to set up the pi, have followed you tutorial but as soon as I add another share I have to log onto the pi from the windows explorer and get permission denied.

    Do I have to have a user on the pi for every windows user?

  8. Bobster says:

    Brilliant setup thanks for this, just come into one snag, I have followed your install letter for letter BUT (I have everything on a 2TB hdd)
    I get this when trying to install samba: this is as far as I get……….

    Do you want to continue [Y/n]? y
    Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main samba armhf 2:3.6.6-6+deb7u5
    Err http://mirrordirector.raspbian.org/raspbian/ wheezy/main tdb-tools armhf 1.2.10-2
    Error writing to output file – write (28: No space left on device)

    lots more lines but all say error

    /tdb-tools_1.2.10-2_armhf.deb Error writing to output file – write (28: No space left on device)
    E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?

    Any suggestions? I tried running rasp-config
    but it says /dev/root is not an SD card. Don’t know how to expand
    Thanks for making this install guide

    • Mel Grubb says:

      I’m not sure which steps you’ve taken so far, but if you’re still booting from the SD card, make sure you expanded the filesystem from raspi-config (See part 2 of the series). If you’ve done that, and then moved everything to boot from the hard drive, then make sure you expanded THAT filesystem as well. Since you’re referencing the samba step, I’ll assume you’re not booting from the hard drive just yet.

      • Bobster says:

        Thank you for replying so quick, and apologies for my delay, I was going over the code.
        NO IDEA……
        I did the squady touch, I went through the coding again, didnt change anything, just went through the steps.
        All of a sudden….wam bam thank you mam, it statted as it was supposed to.
        Thanks again it shows your site is still up and running.
        Carry on the great work and I shall carry on from installing samba…
        Happy chappy…8-)

  9. DavidA says:

    Thanks very much for these articles. I am planning to build a home file server based on them.
    In your disclaimer you say “This is a wide-open file share. Anyone on the local network can add, edit, or delete the files it contains.” I’m not worried about users on the local network, but the network will also be connected to an ADSL router. Does that present a security problem from outside threats?

    I wonder if you would like to add a follow-up article about how the Samba share could be made more secure?

    • Mel Grubb says:

      You’d have to go out of your way and open firewall ports in order for anyone outside the local network to see your shares, or place the server in the dmz. If you’re not doing either of those things, then you’re fine.

  10. Hey Mel,

    Thanks for the wicked article. I wasn’t quite sure how to ask you this, nor do I know if you’ll have an answer, but I’ve been having a few issues around here. First and foremost, I’ve been running into problems with my ssh’ing, that I wasn’t having before. After a period of time, the connection will either get laggy or die altogether, reporting a broken pipe on my mac. I never used to have this issue, although before I was actually using the pi as a wifi access point, meaning I was connected to its own local network anyways.

    This might be the cause of my actual issue: even having configured everything fine up to this point, my connection is extremely buggy. Once I had Samba installed to the point where I could see the pi on my home computer, I never succesfully managed to connect to it – it would always time out. I figured I’d try restarting the process, as I may have made a mistake, but now I can barely even load webmin. Any ideas here? Could it be the wifi dongle I’m using? Its from the pi store, I’m not sure what the issue might be.

    • Mel Grubb says:

      Since its affecting everything, I don’t think Samba is to blame. I have a Wi-Fi dongle too, but I’ve never used it long-term before. I keep my server wired. If you could plug the Pi in, it might at least eliminate Wi-Fi as the culprit.

  11. Reggie Davis says:

    I’m not sure if you still monitor this page, but I’m having difficulties on setting up shares. I have setup my router to always set the pi’s ip address to When I visit from my main windows 7 pc, it says “This webpage is not available, ERR_CONNECTION_REFUSED”, or when trying to view it from the pi’s browser, it says “Oops! It was not possible to show this website”.

    I have triple checked my ip adress using ifconfig, and have verified it’s correct, as vnc is working just fine. Any suggestions would be greatly appreciated!

    • Mel Grubb says:

      Clearly the pi is running, and at the right address, so that just leaves Webmin itself as the culprit. I know the instructions still work, even on the new Jessie version because I’ve built two systems just recently, and Webmin works on both. Double check all the Webmin installation steps and make sure nothing was missed.

      • Reggie Davis says:

        Well as it turns out, I didn’t follow your entire tutorial step process. I skipped the Webmin section. I have completed it, and now I am able to login. Sorry for the amateur mistake.

        I’m currently working on installing an external HDD, but need to purchase a powered USB hub.

        Your tutorials are the best I’ve found out of the thousands out there. Keep up the awesome work!

  12. DavidA says:

    Hi Mel, thanks for your articles. I hope to get started with building a Pi home server soon, but have a couple of questions. Firstly, do you run your o/s from the SD card or from a separate partition on the hard drive? Secondly, I think I’d like to use ext4 to benefit from its better performance over NTFS; would you have time to add some notes on how to do that please?

    • Mel Grubb says:

      At the moment I run the OS from the SD card for convenience in backing it up. My next build will use an SSD for the system drive, just to see what happens. As for ext4, pretty much everything is the same except that you can’t just move the drive to a Windows computer and write to it anymore, and file and directory permissions will have more of an influence.

      • I am running the system (boot) from ssd. Once setup I transfered the boot onto a smaller ssd (from 4 gig card to an 800 meg card (very old card), having a backup on the NTFS 2TB of both boot records and System files, seems to work great. I was thinking of ext4 instead of NTFS but as you mentioned in the build guide it helps with plugging the drive into a Wndows pc.

  13. DavidA says:

    I’m just wondering whether it would be worth providing a small partition on the hard disk, to be used either for storing the root filesystem or for system logs etc? I’m wondering whether continual writing to the SD card is a good idea. Am I over-worrying 🙂 ?

    • The way I get it is the SD card can or would get re written too many times and some cirruption may take place after so mant re writes, hence why I only have the boot on the raspberry sd card. As the raspberry needs a boot sector only to read the ExtHDD with the OS on.

    • Mel Grubb says:

      That’s covered in the entry about adding a hard drive. SD cards eventually wear out, but it takes a really long time. You get some speed boost by booting from the hard drive which may make it worth your while. You’ll never get the boot loader off of the hard drive though, so the SD card will still be needed no matter what, but it will only be used briefly when booting up. I ran my own system entirely from the SD card for over than a year because I found that it didn’t LIKE voting from my external RAID box for whatever reason. I never wrote out the card in that time. My next rebuild will use a proper SSD for the system drive, and the RAID box only for storage.

  14. Pingback: CrashPi – An off-Site backup for the whole family | MelGrubb.ToBlog()

  15. DavidA says:

    Hi Mel, thanks for these instructions, I now have a Samba server running on the Pi, which one of my Windows 7 laptops can see fine. The strange thing is that our other Windows 7 laptop can’t see the Samba share. Both laptops are on the same Workgroup and can see each other. Hard to find a solution for this on the web. Just wondered whether you might have any suggestions please?
    Best regards, David

    • Mel Grubb says:

      Since can see each other, I’m puzzled too. Otherwise I’d suggest that network discovery and sharing is enabled on the other machines.

    • Anthony says:

      I had the same problem. In my case the problem was solved by typing //”server name” in the run command line in windows. After that the server appeared in the network list. It seems as if the computer had no connection issues, it just didnt show the server in the network list for some reason.

  16. Assos says:

    Mel, thank you very much for your excellent guide. I set up Samba following your instructions. I tried to transfer files but the speed was very slow. I own a Raspberry Pi Model B+ that is connected directly to my router. No matter what is the size of the file I see that 100MB is transferred to or from Raspberry is ~3mins 40secs, which is very bad.
    Can Samba on Raspberry have better transfer speed? Is there any tweak I can make?
    Thank you in advance.
    FYI if I make a wget file from internet the speed is very good ~450kbps

    • Mel Grubb says:

      I have not seen slowdowns quite like that, but I can tell you that normally the speed of the medium you’re writing to has a lot to do with it. Were both kinds of transfers writing to the same place? If the download was to a hard drive, but the network copy was to the SD card, that would explain everything. Also, the relative load when you were copying might have something to do with it. For instance, copying a lot of media in over the network into the directories that MiniDLNA is “watching” would slow things down because MiniDLNA is trying to index the newcomers. Basically, there are a lot of variables, and you’d have to eliminate them to be sure. Download something straight from the Pi into a public shared folder, and then copy something in over the network to the same place. Just make sure that it’s not a file that anything is trying to react to. That’s the only way to get a “fair” comparison between the two.

  17. Anthony says:

    This series has been great for me so far as an intro to Linux, thanks for setting this up.
    I got samba working but if I connect the HDD to a windows machine it does not show up under my computer. When I go to windows drive manager it detects the drive and the two partitions that were set up in the previous part but I cant read/write in the ‘data’ partition without formatting it. Formatting the ‘data’ partition also stops the home server from correctly booting once you plug the drive back in. Do you have any idea what causes the drive to not be compatible with windows?

    • Mel Grubb says:

      Did you format the data partition as NTFS? If you went the ext4 route, then Windows is not going to be able to read from or write to the drive without installing extra drivers. I have heard one other person say that partitions formatted as NTFS directly from the Pi weren’t working with Windows, which is not the way it used to behave. I’m not sure if something changed in Jessie or what, but you’re not the first to mention this. If you haven’t already populated the drive, or have somewhere to stash your stuff temporarily, I’d recommend formatting the data partition from an actual Windows machine. No-one has yet reported a problem with that. Just be careful to format the right partition so you don’t overwrite the OS.

      • DavidA says:

        Hi Mel
        I had the same problem as Anthony. I did what you suggested, i.e. reformatted the data partition using Windows as NTFS, leaving the system ext4 partition untouched. But when I reconnect the drive to the Pi, the Pi fails to boot. I think that Anthony is actually reporting the exact same situation.

        I wonder whether reformatting with Windows has changed the GUID or UUID on the disk and that is mismatching with the ones we entered in the config files in your step 6? I don’t know what else the problem might be.

        As a general point, I am using Jessie – so maybe something has changed there as you say.

      • Anthony says:

        Parted states the data partition to be in NTFS. I have already transferred my info onto the drive at this time. If it was not obvious in my previous post, I am able so browse the contents of the server via network with no problems. If I had not already filled my drive, I would have tested Davids theory about the GUID.
        The formatting that I had mentioned in my original post was done on Windows as David mentioned.

      • Mel Grubb says:

        I think I see what you mean. Reformatting the drive would probably change the guid, but you could find out the new one using parted like before, and edit fstab to re-mount with the new I’d. You might want to remove the line from fstab first if that’s causing boot problems, though.

  18. DavidA says:

    Just to report that I have fixed this problem as discussed. The UUID of the data partition had changed as a result of the Windows format. I determined the new UUID using:
    $ blkid
    and then applied the new UUID to /etc/fstab by editing it with nano
    (this was all possible even though the boot hadn’t succeeded).
    The Pi now boots correctly and the data partition is again available via Samba.

    BTW I am thinking of reverting the system partition to the SD Card (currently it’s on the USB drive). I think that may allow the USB drive to sleep – it never does currently.

    • DanL says:

      I’m having the same issue as you. However, I cannot see my drive on my Windows machine in Explorer. It shows up in Disk Management but I don’t have the option to format the partition, only to delete it. How did you format your drive using Windows? Thanks!

  19. Mel Grubb says:

    Yes, if you want the drive to sleep, then using it as the OS drive would not be a good choice. Just make sure you take backups of the SD card now and then because it will eventually croak. The better the card you use, the longer it will take for that to happen, though.

  20. Paulo Gomes says:

    HI Mel

    I have followed all your instruction successfully from start to finish, installing only what I needed (i.e: no transmission for me as I don’t need that, nor Own Cloud)
    My issue is that, when I boot up the pi with auto-login, all works out of the box, and I can see my Raspi Shared folders in my network, BUT after a while(say 30min-1h) the shared ceases to be seen by my network.

    The PI continues to be accessible and webmin tells me the samba server is still running, so I’m thinking maybe the HDD goes to sleep (?)

    Any thoughts on this?

    • Mel Grubb says:

      That seems like a reasonable conclusion. I have heard of others having problems with sleepy drives. The thing is that the drive should wake back up when used. What happens if you try to access the drive by connecting over ssh and then looking at it directly?

  21. Ryan Mann says:

    First off, Mel, you rock!! thanks for putting this together. Addressing the Mac issue, but potentially greater as I haven’t attempted connecting from other client types… Even though we set WINS server to On in Webmin/Samba, it doesn’t seem to be updating the samba.conf (not a mac problem specifically but will affect Windoz). I also had to add a few other settings to the samba.conf (force user = pi might have been the golden goose, given the restrictions on the root account on RPI), as well as chown the share directory back to pi. Most of these instructions can be found here: http://www.htpcguides.com/create-samba-share-raspberry-pi/

    Can’t wait to get the CrashPi functionality working… onto the next lesson! Thanks again!

Leave a Reply to Mel Grubb Cancel 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 )

Facebook photo

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

Connecting to %s