How to share an external USB hard drive from Ubuntu to a Windows network

tux_windowsUpdate 25 July 2015:
I’ve just had to replace my media server and re-perform these instructions. Somewhat surprisingly they hold up under my current Ubuntu 14.02 LTS/Windows 8.1 setup. I’ve also made small changes to the text which now has you launching the Samba Configuration GUI from the command line instead of from the Gnome menus as the original version wasn’t all that much help if you weren’t running Gnome Classic.

***

I’m in the process of taking an old desktop and turning it into the house’s media server, taking most of the grunt work off of the computer I use to do my “real work” on. The media server is currently running Ubuntu 13.04 and it was sharing the small 80GB internal hard drive across my Windows network just fine. However, when I attached an external 3TB USB drive to the server, it was recognized, and I could right-click on it and tell it to share, but when I tried to access it from the Windows machine in the living room, it would not give me access. Many Google searches later I assembled the correct steps to get it to work. So, as a record for next time, and in hopes of helping someone else with some specific instructions, here they are:

  1. Connect and mount the drive to the Ubuntu computer. (The format of the drive, NTFS vs EXT4, doesn’t seem to matter for this to work so I ended up formatting it as NTFS for future portability.)
  2. Do not right-click on the drive and go into the sharing options via the drive’s properties. This will not work.
  3. Make sure you have Samba installed. (You can find it in the Ubuntu Software Center titled “SMB/CIFS file, print, and login server for Unix”)
  4. Install, if you haven’t already, install the Samba GUI. (Also in the Ubuntu Software Center titled “Samba” with a description of “Create, modify, and delete samba shares”.)
  5. Open a Terminal session and run the Samba GUI from the command line with # sudo system-config-samba
  6. File|Add Share
  7. Browse for the drive you wish to share and select it
  8. Change the share name if you’d like to. (For this example my share name is “Media01”)
  9. Check “Writeable” if you wish to be able to write to this drive from other computers on the network.
  10. Check “Visible” if you’d like others to see the share while browsing the network.
  11. On the Access tab, select “Allow access to everyone” (This will avoid the problems of having to specify usernames and passwords in programs like XMBC and MediaPortal.)
  12. Click OK (You should be done at this point but you’re not. This is what caused me the most headaches to find.)
  13. Back at the command line:
  14. # cd /etc/samba
  15. # sudo pico smb.conf (Feel free to use the editor of your choice. I like Pico.)
  16. Scroll to the bottom of the file. There you should find [Media01] (remember that’s the name of the share I created.)
  17. Add the following new line in that section: force user = username (In my case username is “msauers” since that’s the username I log in to Ubuntu with. Replace with your username.)
  18. Save the edited file.
  19. # sudo restart smbd (restarts Samba)

That should do it. You should now be able to access the shared drive from any Windows computer on your network.

51 Replies to “How to share an external USB hard drive from Ubuntu to a Windows network”

  1. Thanks Michael, you saved me. Couldn’t figure out why the storage disk diden open as a shared disk from Win7. After days of googeling and trying everything out there I was about to give up ubuntu. Then I found this and it worked for me! Thanks!

  2. Many, many thanks from Holland (Europe)! Tried it for month and coudn’t found out what was wrong! You saved my day!!

  3. Thank you so much! This trick allowed me to share my external hard drive files and the files saved in my windows 7 partition. This information should be more easily found, and the samba gui should assume the force user permission. Thanks again!

  4. I’ve tried almost every website looking for answers – Ubuntu Forums, Superuser, etc – everywhere! They all told me to set up Samba CLI and then sharing it and I wasn’t able to.

    Thanks a lot man. I owe you one! 😀

  5. Michael,

    As someone from just west of you I thank you for your clear, concise directions. Step-by-step and now I can see the drives on my Win7 machine (albeit after typing the IP address into the Win Explorer bar – but that’s another troubleshooting).

    Now, on to setting up the access to the NAS for the media server.

    Next time I’m doing work in Lincoln, I’ll buy you a drink!

    KATrimels
    Cheyenne, WY

  6. I couldn’t get it to work until I followed these added instructions in the Ubuntu store for 14.04 – Thanks for getting these instructions together – I definitely wouldn’t have been able to get it to work without them.

    Fix For Ubuntu 14.04 .. Make sure Samba is not installed. Then open terminal & type “sudo apt-get install gksu” (Without The Quotes).

    Then type gksu-properties

    In the dialogue that follows set authentication mode to “sudo” and grab mode to “enable”

    Now Install Samba everything should be working & it show up on Unity Bar & Search.

    Basically its the same steps Trevor Lane Ray did for 13.04

  7. thanks a lot man.

    it;s hard for us newbie to understand what’s going on with that new os we<re trying and it<s thanks to these tutorials that we get to now a little more about linux.

  8. hi!!
    i try to share my hhd with my android smartphone (use es file explore on my nexus)
    but the phone give me this results:
    access failed, it may caused for:
    – wlan off
    – the server smb not accessible
    – invalid IP address
    – blocked from firewall
    – the service smb is off.

    please help meeee!!

    thank u very much

  9. Merci bcp !!!!

    Thank you. I search long time to get an answer to WHY it didn’t work and you hit it !

  10. Awesome tutorial… fast an easy to accomplish.. thank you.. I’m learning a lot with this.

  11. Thank you Michael,

    I had been using a RT-N56U wireless router to share a USB drive, but after a firmware upgrade the feature no longer works. So after a bit of searching I came upon your article, which worked like a charm in Ubuntu 12.04!

  12. Thank you, Michael
    That’s an elegant fix for the external usb drive sharing problem i had on my ubuntu 14.04, your solution in 1 minute saved me after hours (!) of tries and googling.
    Egor / Kiev

  13. I tried Linux about a year ago but gave up because I could not enable a home network with 1 linux and 4 xp machines. Thanks to all the folks who made Unbutu 14.04 LTS work so much better than what I tried to use before. Thanks so very much to you Mr. Sauers for gathering and publishing just what I needed to finish the networking! Now I am at 3 linux and 2 xp machines.

  14. External media are problem when you are a simple user
    with now rights.

    But for me it was simple :
    -Linux Debian Jessie with Mate
    -Samba installed and configure in the same workgroup
    -Add user to samba “smbpasswd -a someuser”
    -then in term(cli) while in Mate
    sudo “filemanager_share_integrated_fonctionnality”
    (like caja, the Mate default file manager)

    Then share what is in the /media directory
    my 2 EC !

  15. This worked and I am as happy as I can be! Been struggling with this for a long time. 🙂

    Alejandro

  16. Thanks so much from Denmark. Driving me nuts, but now it works like a charm!!!

    Allan

  17. Doesn’t seem to work. Still can’t see the share on the Windows based machines. Any ideas?

  18. a couple of things:

    1) in the bottom of smbd.conf – uncomment “Browseable”
    Otherwise you cannot browse the shared volume – same “You do not have permission” error.

    2) Restart smbd service via init.d as restart smbd did not work. So i did /etc/inid.d/smbd stop followed by /etc/init.d/smbd start

    Worked fine after that.

  19. it works also on 16.04!
    although command “sudo restart smbd” doesnt work
    workaround:
    “sudo service smbd stop”
    and then
    “sudo service smbd stop”

  20. Overall prime content shared. Thank you man. Saved me lots of hours research in vain. Work on Ubuntu 16.04 sharing an external hard drive.

  21. This is still useful today on Ubuntu 18.04. I was breaking my head over this for a few days now and gave up in the past trying to share a folder from my external drive on Ubuntu to access from Windows 7/10 w/ no luck. What worked for me on this was to add force user = user (used to logged in to ubuntu) to the /etc/samba/smb.conf file.

    Thanks for the contribution. As I can see from the comments it has helped many over the years.

Leave a Reply

Your email address will not be published. Required fields are marked *