Share external drive using Raspberry Pi

DIY Dropbox, Apple iCloud, Google Drive alternative

Storing bunch of photos, videos, old files in the cloud is handy but it costs you extra fee each month. Storing them in the external drive is much cheaper option with one drawback: you need to connect it to your machine to access and copy files. What if you could share it on your home network? That would be great for a few reasons:

  • You will have instant access to the contents from any device in the network

  • Connect and forget

  • Free

Good news is you won't need a lot to make it work:

  • External drive

  • Raspberry Pi (4B in my case but any version should work fine)

  • Home network (WiFi router)

And setup process is also fairly straightforward.

Setup Samba server on Raspberry Pi

  1. Connect External Drive:

    • Plug in your external drive to one of the USB ports on your Raspberry Pi.
  2. Update and Upgrade:

    • Open the terminal and run:

        $ sudo apt update && sudo apt upgrade -y
  3. Install Samba:

    •     $ sudo apt install samba
  4. Configure Samba:

    • Open the Samba configuration file:

        $ sudo nano /etc/samba/smb.conf
    • Scroll to the end and add:

        plaintextCopy code[ExternalDrive]
        path = /path/to/your/external/drive
        writeable = yes
        create mask = 0777
        directory mask = 0777
        public = no

Replace /path/to/your/external/drive with the actual path to your external drive.

  1. Create Samba User:

    • Set a password for the default pi user (or create a new user):

        $ sudo smbpasswd -a pi
  2. Restart Samba:

    •     $ sudo service smbd restart

Now, you should be able to access your external drive through Samba. Connect to it using your computer's file explorer with smb://<Raspberry_Pi_IP_Address>/ExternalDrive.

Connect to the Server

In my case I accessed using my Macbook but for other devices process should be similar:

  1. Open Finder.

  2. In the menu bar, select Go and then Connect to Server... (or simply use Cmd + K shortcut).

  3. Type the following in the "Server Address" field:

    •     $ smb://<Raspberry_Pi_IP_Address>/ExternalDrive
    • Replace <Raspberry_Pi_IP_Address> with the actual IP address of your Raspberry Pi.

  4. Authentication:

    • Click the Connect button.

    • Enter the username (likely 'pi') and the password you set with sudo smbpasswd -a pi.

  5. Access Files:

    • Once connected, you should see the contents of your external drive. You can now copy, paste, or manage files as needed.

That's it! You're now connected to your Samba server from your MacBook. Let me know if you encounter any issues.