As I already mentioned in previous blogs, I’m working on automating my home. As I had some problems with storage on my devices I decided to, as I already had this Raspberry PI in my hall closet why not add a fileservices sharing thing to it?

Its, as always when it has been done, easy. First of all, get yourself a external harddrive. I don’t care how big, I used one with 4 TB.

First things first;

sudo apt-get update
sudo apt-get upgrade

Mount and stuff!

Step one is easy, connect the USB drive to your RPI, that means physically plugin the cable into it. Nothing more nothing less, job done, pretty good. Next we will have to mount this drive, what I did was mounting it to /media/usb1 (see the 1 is for if I decide to add more later.)

Find out the UUID of the disk by executing the following command:

ls -l /dev/disk/by-uuid

Most likely this will confuse the crap out of you. It did out of me anyway. I’ll make it easier, look for a line that says /sda2 (2 is mine, because its the second drive, could be higher or lower in your case) Copy the UUID of this disk.

Now, install an NTFS package so it works with default (windows) formatted disks:

sudo apt-get install ntfs-3g

Next we will have to create a folder that we can mount the contents of the disk to; create it:

sudo mkdir /media/usb1

We will have to find the gid and uid to fill in in the fstab file; I’m using the user PI here, if you have another user by sure to update these statements;

id -g pi
id -u pi

Now prepare your line somewhere with the information found before;

UUID=your_uuid /media/usb1 auto nofail,uid=your_uid,gid=your_gid,noatime 0 0

Open the fstab file;

sudo nano /etc/fstab

Add the line we composed above at the end of this file, save it and exit.
Last 2 steps here are to unmount the disk and mount in our way.

sudo umount /dev/sda1
sudo mount -a

Thats mounting!

Samba baby!

Install samba-data
sudo apt-get install samba samba-common-bin

Its seriously easy; prepare this statement:

path = /media/usb1/
create mask=0777
directory mask=0777


  • You want to change the content between [] its the name of the share
  • If you mounted the USB drive somewhere else, alter line 2
  • Public no is a bit of security, you could put it to yes ofcourse.

Open the Samba config file;
sudo nano /etc/samba/smb.conf

Scroll to the bottom and paste the prepared statement. Save it, exit.
If you used public=no you will have to create a user that has access to this share, thats quite easy, for instance, to add the user pi;

sudo smbpasswd -a pi

Enter the password you want for this user, confirm it and lastly reboot Samba;
sudo systemctl restart smbd

Now you should be able to connect from any device in your network to this Samba share.

  • For Windows, open Explorer, add Network Disk use: \\192.168.x.x\externalusbshare
  • For Apple, in Finder open the Network, find your RPI and login as the user just created.
  • For Linux, I don’t know, good luck! 😉

Thats that! Happy hacking :-)

Want to get an email when a new post is placed? Subscribe!