Hackviking He killed Chuck Norris, he ruled dancing so he took up a new hobby…

15Sep/150

Raspberry Pi as a torrent server

A Raspberry Pi is a great for creating an always on torrent box that can take care of all your downloading and seeding. If you combine it with a NAS and a Raspberry Pi Kodi media center you will have a really sweat setup. The Raspberry Pi has a low power consumption, I run my of the USB port on my NAS. It also have no fans so it's quiet! In this guide we setup Transmission on a Raspberry Pi which includes both a web gui and third party apps for IOS and Android.

I presume that you have some basic knowledge of Linux and the Raspberry Pi. If not you might need to check out the installation guide for Raspberry Pi. When you have your Raspberry Pi up and running just follow the guide below. Use an image and not NOOBs it will come back and haunt you!

Last time installed my torrentPi I used Noobs and now, when I runned out of diskspace, I couldn’t just clone the SD-card to a larger one and expand the filesystem. If you instead use Win32DiskImager to install Raspian you will be able to upgrade your space later on.

After you boot up the system run “sudo raspi-config” to set your hostname, timezone and other settings. For this implementation make sure you disable desktop (scratch) functions, that SSH is enabled and also set the memory split to 16Mb. We will only use web interface, ssh and the client software to access the system so wasting memory on the GPU is just stupid.

Storage

So first of all we need some place to store the downloads. You can connect a USB drive if you want but it will only be USB 2.0, you can connect USB 3.0 devices but the speed will be reduced. I prefer to use a share on my NAS. If possible make sure the NAS has support for NFS (Network File System). It’s widely used by Linux systems and have much better performance than the regular SMB (Samba) shares that windows use.

I have an NSF share named “download” on my NAS (192.168.0.5:/nfs/download). My NAS supports both NFS and Samba on the same shares so I can access the share from my PC as well. On the share I create two folders named “incomplete” and “completed”.

The PI needs to mount the share automatically when it boots to support reboots without breaking our setup. Connect to the raspberry via SSH or keyboard & HDMI and make sure you are in the root folder (“cd /”). I usually do a “sudo su” so running elevated commands is smother. If you don’t do that you need to add “sudo” at the beginning of each command line below.

Raspian comes with nfs-common pre installed but not portmap. To make sure all is latest version run:

apt-get install nfs-common portmap

Rpcbind, part of the portmap package, doesn’t start by default on raspian. So first start it…

service rpcbind start

Then we need to make it persistent so it will start after reboot.

update-rc.d rpcbind enable

Now I create a folder to mount the share to. I usually like to keep them in the /mnt folder but you can more or less put it anywhere you like.

mkdir /mnt/download

Now I mount the share to that folder. My server is on ip 192.168.0.5 and all NFS shares is under /nfs.

mount -t nfs 192.168.0.5:/nfs/Download /mnt/download

Now you can see the share if you run df -h:

192.168.0.5:/nfs/Download  5.5T  2.4T  3.1T  44% /mnt/download

You can also go into the /mnt/download folder and do an ls to make sure you see the completed and incomplete folders that was created earlier. If we reboot the raspberry now we will lose the mounted share so we have to make it persistent. We edit the /etc/fstab with nano like:

nano /etc/fstab

At the bottom we add this line:

192.168.0.5:/nfs/Download /mnt/download nfs rsize=8192,wsize=8192,timeo=14,intr 0 0

Exit nano and reboot the raspberry.

It took me a long time to actually get this up and running, I missed to change the eth0 DHCP on. Both will work but if the manual is used the Pi will acquire the IP to late for the NFS drive to mount. I wrote about this fstab problem yesterday.

But make sure that you change

iface eth0 inet manual

to:

iface eth0 inet dhcp

in the /etc/network/interfaces config file.

Install Transmission

So now that you verified that /mnt/download mounts correctly on each reboot let’s install transmission!

apt-get install transmission-daemon

So after the install you can browse to: http://{the Pi IP}:9091 and you will see this:

Access denied after Transmission install

Access denied after Transmission install

So we still need to configure the basics of transmission. The configuration is kept in JSON format here: /etc/transmission-daemon/settings.json Before we can change any settings you have to stop the service:

service transmission-daemon stop

If you don’t do that the service will just overwrite your changes. You can go around this by doing service transmission-daemon reload after your done editing but I prefer to just stop the service. Then we can start edit the settings:

nano /etc/transmission-daemon/settings.json

There are several fields that we need to change. Below is a brief description of each one:

  • download-dir: Where transmission should keep downloaded files. In this example /mnt/download/done
  • incomplete-dir: Where the data is stored during download. You should never keep this on the local SD-card. You will end up filling it up and breaking the card with too many writes quickly! In this example we use /mnt/download/incomplete
  • incomplete-dir-enabled: We need to set this to true otherwise transmission doesn’t use the incomplete directory.
  • rpc-password: If you don’t want to remember the one long complex one in there set you own.
  • rpc-username: Default is transmission, you can set your own if you want.
  • rpc-whitelist: This defines from what IP your allowed to access the transmission installation. I use 192.168.*.* to cover my two subnets that I use at home.

Now you should be able to access the install via http://{the PI IP}:9091 with the username and password you setup.

Port config

But we are not done yet! If you open up the settings in the web interface (the wrench in the lower left corner) and click the “Network” tab, you will probably see this:

Peer listening port closed

Peer listening port closed

If your router supports UPnP just tick the “Use port forwarding from my router” and you will see the port open. Otherwise you have to configure port forwarding on your router for the configured port to the RaspberryPi IP. If you need to setup a manual port forward you should also setup a DHCP reservation for the Pi or configure it with a static IP. Otherwise the Pi might get a new IP after a reboot and the port forward will point to the wrong device or no device at all!

Now you can add torrents to Transmission via the web interface or download the desktop app if you want.

Comments (0) Trackbacks (0)

No comments yet.


Leave a Reply

No trackbacks yet.