Photo by Mediocre Studio on Unsplash
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
Connect External Drive:
- Plug in your external drive to one of the USB ports on your Raspberry Pi.
Update and Upgrade:
Open the terminal and run:
$ sudo apt update && sudo apt upgrade -y
Install Samba:
$ sudo apt install samba
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.
Create Samba User:
Set a password for the default pi user (or create a new user):
$ sudo smbpasswd -a pi
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:
Open Finder.
In the menu bar, select Go and then Connect to Server... (or simply use
Cmd + K
shortcut).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.
Authentication:
Click the Connect button.
Enter the username (likely 'pi') and the password you set with
sudo smbpasswd -a pi
.
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.