In order to silence my every so slightly aging iMac I decided to swap the mechanical HD for a SSD. This also had the added benefit of increased speed, with one downside. A large reduction in storage capacity, I had gone from 1Tb down to 240Gb.
Around the same time I had upgraded my Dropbox to the Pro account, 1Tb of storage. I thought my storage problem would be solved. Oh wait, hang on, I still need the files locally to sync with Dropbox.
This problem set me down the path of configuring my Dropbox to sync files outside of the Dropbox folder. But instead of the folder being on an external drive (too noisy!), I would place the external folder on a Raspberry Pi with an external drive, placed in another room. No noise!
The following is a guide on how you can configure a Raspberry Pi with a Samba share, which in turn can be symbolically linked on OS X to a folder within Dropbox. Therefore, allowing you to have a large synchronised version of your Dropbox files locally.
What you need
Raspberry Pi – Assuming Raspbian installed and running
External HD – For the Raspberry Pi
Configure the external HD
For this particular setup I was concerned about speed. Therefore, I chose the ext4 format for the external drive. You can of course choose any other format such as HFS, NTFS or FAT for your drive, but this guide specifically deals with ext4.
Identify drive to format
To ensure you format the correct drive use the following command at the terminal on your Pi.
Your external drive (assuming only drive plugged in) will likely be listed as /dev/sda1 followed by the UUID, take note of this, as you will need it later.
Format the drive
The following code will format the drive on sda1 (change to your drive if it differs) with ext4.
sudo mkfs.ext4 /dev/sda1
Create a folder to mount the drive to
I chose the name “cloud” for my folder, but feel free to change this.
sudo mkdir /media/cloud
Auto mount the drive
In order for the USB drive to mount on reboot we have to amend the fstab file with our drives UUID, mount point and permissions. You can obtain your drives UUID with the blkid command from above.
sudo nano /etc/fstab
We need to add the following line replacing XXXX with the UUID of your own drive
UUID=XXXX /media/cloud ext4 defaults 0 0
Test the auto mount
To test the auto mounting without a reboot type
sudo mount -a
Hopefully, there should be no errors and you can check the drive has mounted wiwth the df command. If you did receive an error, go back to the step above and make sure there is not a type within the fstab file.
To ensure to the user pi has full permissions issue the following commands
sudo chown pi:pi /media/cloud
sudo chmod 777 /media/cloud
First we must install Samba
sudo apt-get install samba samba-common-bin
Next we have to configure the smb.conf to share our USB external drive with users on the network.
sudo nano /etc/samba/smb.conf
At the bottom of the smb.conf file add the following text. This will share the /media/cloud directory. Which we mounted our USB drive to, as “cloud”
comment = Cloud
path = /media/cloud
valid users = @users
force group = users
create mask = 0660
directory mask - 0771
read only = no
This configuration assumed you will login to the Samba share with credentials. In order to add the user pi to samba use the following.
smbpasswd -a pi
Raspbian configuration complete
The configuration on the Pi is now complete. Assuming you followed all the naming conventions above. You will now have a share on the server “raspberrypi” (the default server name on a Raspbian server), named “cloud”. Which, you are able to connect to with the user “pi” and the password you chose from the final step above. Now all we need to do is configure Dropbox on OS X.
This is the simple part! In the OS X finder there should be a server in the sidebar named “raspberrypi”. Click on this and then click the “connect as” button. Use the credential from the final Samba configuration, so username “pi” and the password you chose.
Link an external folder to your Dropbox
Open the terminal on OS X and use the following command
ln -s /path/to/desired-folder ~/Dropbox/desired-folder
The easiest way to achieve this is to type “ln -s” at the command line then drag and drop the “cloud” folder from the mounted raspberrypi server to the terminal. Then do the same with the desired folder from your Dropbox account.
And thats it! Now any file you place in the folder in your Dropbox will be stored on the external share on Raspberry Pi. Therefore, not taking up space on your small SSD!
I benchmarked this setup with a very quick and perhaps dirty test. Using nload, I copied over 40Gb of media data. With varying file sizes, from 4Mb to 4Gb. I received an average throughput of 30Mb and a peak of 42Mb. This is absolutely quick enough to use for this purpose, as the files will not sync to Dropbox anywhere near that speed.
Couldm’t you just link a folder in Dropbox to an external drive on your Mac?
Yes, but then you would have the noise of a spinning drive!
But these files are stored on a server, not locally
I used the term local, to mean within my local vicinity.
Will this work with BOX, OneDrive, etc….
Yes, this will work with anything.
Did you just make this complicated to use a Raspberry pi?
Yes, but I love using Raspberry Pi’s for specific uses. They are so cheap and so much fun to play with.