I’ve started writing the original version of this tutorial in 2014, and back then I had less experience in managing Linux users, permissions and services, and also the official OS of Raspberry Pi, the Raspbian was a bit different, too. The below how-to is a major re-write of the original, and it’s intended to be configured on a Raspberry Pi 3B+ and Raspbian Stretch Lite (2018-06-27).

It’s a work in progress, so please be warned!

Now, on to the interesting stuff…

Downloading (legal) content using torrents is very convenient, but if you plan to keep the files “seeding” which is the term to allow them to be uploaded back to other users, then you’ll need to keep your computer running 24/7 which won’t be good for your electricity bills. For this reason it’s a nice idea to use a Raspberry Pi as a “torrent server” a.k.a “seedbox” which will run day and night, as it’s power consumption is tiny compared to a laptop, let alone a desktop PC.

We’ll be using Transmission as a torrent client, which can be installed as a “daemon” running in the background all the time on the Raspberry Pi.

This guide assumes that you already have the following:

  • You have wired up your Raspberry Pi (good quality power supply and USB power cable) and Ethernet (I don’t recommend WiFi for this)
  • You have Raspbian Stretch Lite imaged with Etcher on your microSD card, which can boot up and log into the pi user
  • You have assigned a static IP address to it, so we always access it on the same IP; either on your router or in the OS

When the above are ready, please SSH to your Raspberry Pi and install Transmission torrent client like this:

sudo apt-get update -y
sudo apt-get upgrade
sudo apt-get install transmission-daemon

Installing transmission-daemon will immediately start running it’s service, so before we do any changes in configuration of it, we better stop it.

sudo systemctl stop transmission-daemon.service

Deciding which user should run transmission-daemon

In Linux every service is running by a certain user. It makes a big difference if you’re running a certain script as root, or a system user, or a normal user, since every user has different permissions on the system. Generally, it’s a bad idea to run any service as root, as it has security implications.

If we’re using Raspbian, we usually run our commands and scripts as Raspbian’s default user pi, but some programs have their own service user, which is meant for running that certain service. This was we can limit that program’s access to files or other services, and in case if the program or service would misbehave, we can limit it’s impact to the whole system.

The transmission-daemon is a kind of service which creates a service user for itself when you install it. It’s service user is called debian-transmission. We can say that transmission-daemon is meant to be run in the name of it’s service user debian-transmission.

Transmission works in a way, that it loads it’s configuration from a specific folder within the home folder of the user which is running at the location $HOME/.config/transmission-daemon of the user which is running transmission-daemon. If you’d want to read further on how transmission configuration files work, head over to the transmission wiki’s related page.

Interestingly, the debian-transmission user’s home directory is not /home/debian-transmission as one would expect, the developers set it to /var/lib/transmission-daemon

If we want to check the home directory a user, we can run the below command (I got the hint from here.)

egrep "^{{ transmission_user }}:" /etc/passwd | awk -F: '{ printf $6 }'

The actual configuration file of transmission-daemon is settings.json.

If we intend to use transmission’s default service user debian-transmission, then we will find the config file here: /var/lib/transmission-daemon/.config/transmission-daemon/settings.json.

Although the tranmission developers made one further trick, the above settings.json is just a symlink.

pi@seedbox:~ $ sudo ls -la /var/lib/transmission-daemon/.config/transmission-daemon/settings.json
lrwxrwxrwx 1 root root 38 jan   12  2018 /var/lib/transmission-daemon/.config/transmission-daemon/settings.json -> /etc/transmission-daemon/settings.json

This is how the developers achieved that if you use the debian-transmission user, the config file is actually /etc/transmission-daemon/settings.json.

If you intend to use the pi user, the location of config file has to be different:

Verifying the path to the home folder of the pi user:

pi@seedbox:~ $ egrep "^pi:" /etc/passwd | awk -F: '{ printf $6 }'
/home/pi/

We need to prepare the config file’s location, and create the config file itself, and set it’s permissions:

sudo mkdir -p /home/pi/.config/transmission-daemon/ && sudo touch /home/pi/.config/transmission-daemon/settings.json && sudo chmod 755 /home/pi/.config/transmission-daemon/settings.json

Where do we set the service user of transmission?

Formerly, in older versions of Raspbian where the init system was used, the transmission-daemon’s service user could be set in here:

sudo nano /etc/init.d/transmission-daemon

But the recent Raspbian operating systems use systemd instead of init.d, so we need to look into systemd’s configs to determine by which user (and group!) will transmission-daemon be running.

By default the user config is in this file, and if we want to run transmission as the pi user instead of debian-transmission, we need to set that here:

pi@seedbox:~ $ sudo cat /etc/systemd/system/transmission-daemon.service.d/user.conf 

[Service]
User = pi

It’s better to leave the group as it is:

pi@seedbox:~ $ sudo cat /etc/systemd/system/transmission-daemon.service.d/group.conf 

[Service]
Group = debian-transmission

How will the service user of transmission write to the disk?

sudo usermod -a -G pi debian-transmission

Before we make all the changes we want, we should make sure the transmission-daemon isn’t running. Let’s check the status first. If it’s active and running, let’s stop it. Then check the status again to see if it’s really stopped.

sudo service transmission-daemon status
sudo service transmission-daemon stop
sudo service transmission-daemon status

Then we’ll have to edit the transmission-daemon to run in the name of the Raspbian’s user “pi”, instead of the user “debian-transmission” which is set by default in transmission-daemon.

sudo nano /etc/init.d/transmission-daemon

change this line:

user=debian-transmission

so it looks like this:

user=pi

Now we set the permissions on the folders transmission keeps the config files. If it can’t read and write the configs, it won’t run. As we’ll be running transmission-daemon as the “pi” user, the commands are the following:

sudo chown pi:debian-transmission -R /etc/transmission-daemon/
sudo chown pi -R /var/lib/transmission-daemon/

We need to make sure transmission-daemon will start by itself after every reboot.

sudo update-rc.d transmission-daemon defaults

Now comes the config file.

You can edit it in it’s original location (but it has a long path to enter and remember)

nano /var/lib/transmission-daemon/.config/transmission-daemon/settings.json

So you can also use a this symlink which points to it. It doesn’t matter which you choose, you’ll be editing the same file anyway.

nano /etc/transmission-daemon/settings.json

If you’re looking for some inspiration, you can use my settings.json file which I keep here. Just make sure you change the username, password and other bits and pieces which are relevant to you.

Now let’s see if it starts :)

service transmission-daemon start

You don’t need to use sudo anymore, because we should be able to start it as the user “pi”.

If you use an NFS server to share the files downloaded with Transmission, restart all related services:

sudo exportfs -ra
sudo service nfs-kernel-server restart
service transmission-daemon restart

To test if the transmission-daemon starts OK after a reboot, we should test it.

sudo reboot

After the Pi reboots, we can log back to it via SSH.

Most probably, you will see a banner saying “Warning: transmission-daemon.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.”, so you should do that, but using sudo, as this can only be done as root.

sudo systemctl daemon-reload

Transmission also has a web-based graphical user interface (GUI) which we can use to manage our torrents, it’s very handy. Open a browser on our laptop, and try if we can reach the web interface. Of course you’ll need to insert the static IP of your own Raspberry Pi there.

http://192.168.1.111:9091/transmission/

This should bring up a login box. The username and password are stored in Transmission’s settings.json we have set earlier.