Setting up Syncthing on Raspberry PI 2 as "always ON" device

Yeah, uhm, I think I still owe you a post for some dropbox’ish thing to sync files over multiple devices.
At first I was willing to give seafile a try, but after reading this it became a nono for me.

Fortunately there is Syncthing - a peer to peer based syncing solution that runs on almost any platform.
Another plus: there is an android app and a third party iOS app seems to be in development, awesome!

There is already an impressive number of tutorials for installation and setup out there and the syncthing documentation is great. Therefore I’ll only cover the very specific things to my setup.

Setting up the “Server”

Syncthing is no client-server application.
Files will only sync if at least two devices are running and online. To make syncthing a Dropbox alternative I have one device that is online all the time. It always knows the most recent state of my files.
We will use a Raspberry PI 2 running Arch Linux as our always online device.
Consider the following commands to be executed on the PI.

Step 1: Get the Syncthing Package

# Version might have changed when you are reading this.
curl -OL

Step 2: Unpack the Package

mkdir syncthing
tar xfvz syncthing-linux-arm-v0.11.21.tar.gz -C syncthing --strip-components=1

Nice, Syncthing is now unpacked in a folder called syncthing.

Step 3: Make the Web Interface accessible in your local network

Syncthing brings a nice web GUI that lets you configure your peer. By default it is only accessible from the peer running syncthing.
Since I don’t have desktop environment installedon the PI, I want to access the web GUI from my laptop.
In order to get this working we have to tweak the syncthing config a bit.

First, run syncthing once so it creates all the default folders.

cd syncthing/
# hit CTRL + C after everything booted up.

Now edit the syncthing config with your favorite editor.

vim ~/.config/syncthing/config.xml

Change this line

<gui enabled="true" tls="false">

to this

<gui enabled="true" tls="false">

We can now access the web GUI of the PI via http://IP_ADDRESS_OF_YOUR_PI:8384

Step 4: Run Syncthing on Startup

You may not want to start Syncthing by hand everytime you restart your Raspberry, the guys from Syncthing got your back.

# do the next stuff as root
cd syncthing # if your aren't already there
cp syncthing /usr/bin/
chmod a+x /usr/bin/syncthing

cp etc/linux-systemd/user/syncthing.service /usr/lib/systemd/user/
systemctl --user enable syncthing.service


Syncthing now starts at every boot!

I had some troubles figuring out how to do this proerly so I thought it would be worth mentioning.

Other Devices

If you are running Arch Linux on your machine it is as easy as this

pacman -S syncthing
systemctl --user enable syncthing.service
systemctl --user start syncthing.service

Set up your synced Folders and such

Please see the documentation for all the configuration and Web GUI stuff, it’s very comprehensive.


I am really satisfied with this solution as my Dropbox alternative, everything seems to work well and I hope my
few notes on setting it up on the Raspberry PI will save you some time while setting up your own Syncthing!

TIL: Batch resize images and create animated gifs from command line

Today I needed to combine some of my pictures from my mobile to an animated gif. Since using GUI tools is no option of course, here is how to do it from the command line.
First of all, make sure you have ImageMagick installed on your system.

Once installed you are ready to go.
Assuming we have the following file structure and want all JPEG files to be resized.

├── 1.jpg
├── 2.jpg
├── 3.jpg
├── 4.jpg
└── output

To make them, let’s say 25% smaller, you can run the following command:

mogrify -resize 25% *.jpg

You could also run something like:

mogrify -resize 1600x1200 *.jpg

Note that mogrify will replace your original files with the resized ones, so consider backing up your originals before running this.

After resizing, now create the gif using

convert -delay 35 -loop 0 *.jpg output/animated.gif

and your done, your gif will be placed in the output folder.

Installing Arch Linux on the Raspberry Pi

Choosing the image

There are many use cases for the Pi and therefore you will find a lot of images, that will try to match your needs. Since I just want to run some server applications on the Pi, that need no GUI at all, I will go for the Arch Linux image. There are surely enough other images that will fit the needs as well or even better, feel free to try them out, the installation steps should be the same.
You can find the Arch and many other images on the download site at

Download the image and prepare the SD card

Depending on your operating system, there are different ways to set up the SD card, so it will boot your Linux distribution of choice.
I will try to cover both Linux and OSX by sticking to the command line, since they have many commands in common.(differences will be marked)

First download and extract the image:

curl -o -L
# if your system is missing curl, install it via your systems package manager
# some examples
# on ubuntu: apt-get install curl
# on mac with brew: brew install curl

After downloading is finished, check the integrity of the image. This can save you a lot of pain!
A corrupted download will make you to have to repeat the whole setup again.
Generate the checksum of your download and compare it to the checksum on the downloads page.

# generating the checksum of the downloaded file
# the command could be named sha1sum for some folks

If the checksums are matching, lets extract the zip file.


Note that the extracted file will be named something like ArchLinuxArm-some-release-date-rpi.img.

Put in the SD card format it with your tool of choice to FAT32 and remove it.

Then do

df -h

Now insert the SD card.
Again run

df -h

The additional device listed is your SD card.
In my case it’s /dev/disk2, this will differ from machine to machine. So if I use /dev/disk2 in some following commmands just see it as a placeholder for your device name.

The next step will differ a little whether you are using an OSX or a Linux OS.
The SD card needs to be unmounted now.

# only for mac users
sudo diskutil unmountDisk /dev/disk2

On Linux it should look something like this:

# only do this when you are on a linux machine
umount /dev/disk2

Flashing the image

Alright, now it’s time to flash the image to the disk.
This step will again slightly differ from OSX to Linux.

# on a mac machine the m for bs=1m is written in lower case.
# using rdisk2 over disk2 will give you a nice speed boost in many cases but it's mac only
sudo dd bs=1m if=ArchLinuxARM-2014.01-rpi.img of=/dev/rdisk2
# on linux machines the M is written in upper case an the bs is set to 4
dd bs=4M if=/path/to/your/image.img of=/dev/disk2

Ok, since the image is not that big, flashing will be quite fast.
As the final step eject the SD card.

# mac
sudo diskutil eject /dev/rdisk2

On Linux, clear the write cache, to safely remove the card.

# linux
sudo sync

Now the moment of truth has come. Pull your SD card out of your computer an put it in your Pi!
Notice: put the SD card in before plugging in the power supply.

Login will be root, root. Change this immediately:

# after logging in to the Pi run

Now the Pi should be up and running, awesome!