Raspberry Pi Torrent box

After a couple weeks of being at university, I encountered a problem; the university WiFi wouldn’t allow torrenting. I’m not talking Pirate Bay here, either, I couldn’t torrent new image files from RaspberryPi.org! Sure, it’s not a huge problem but just re-imaging my SD card for this post caused 3 crashed downloads with no explanation. Long downloads, too. I’d heard of using Raspberry Pis as torrent-boxes before so, when I found myself with this problem, I thought why not try it out?

I used a Raspberry Pi Model B with a 4GB SD card and originally a 32GB USB drive but I’m currently upgrading to a 500GB HDD. I mostly followed this tutorial, with a few other bits thrown in here and there. So for the torrent client, I’m using Transmission. It’s got a great web-interface, it works well with NAS and DLNA services. Here’s what I got up to.

Flashing the SD Card and SSH

I use a Macbook and I’ve never properly learned the Terminal way to flash an SD card, so I use this nifty little tool called ApplePi-Baker 2. The SD was flashed with the latest version of Raspbian Lite as of September 2017. I did make one adjustment, however.

I like to use my pis headlessly via SSH, right from the get go. SSH isn’t enabled by default but this can be achieved by adding a file to the ‘boot’ partition of the SD card called “ssh” with no extension. I achieved this simply by creating a blank .txt file, naming it correctly, saving it and just deleting the extension in the macOS Finder.

From there, I was able to insert the SD card, find the pi’s IP address by seeing what’s connected to my router (the device name is just ‘raspberrypi’ from a fresh install) on the router management page found at 192.168.0.1. Then I connected to pi@192.168.0.2 and use the password ‘raspberry’.

Acquiring a Static IP

So as to make sure the pi’s always found at the same address, I’m going to give my pi a static IP. While this isn’t hugely important for just accessing the pi locally, it’ll be pretty necessary for port forwarding and accessing the server from outside my LAN.

This used to be a little more complicated but now it’s insanely simple, through following this tutorial. First up, I ran code to update and upgrade the OS. After that, all I had to do was open a configuration file, paste some code and change the static IP in the pasted code to my desired IP. Sorted!

Mounting the Hard Drive

All this is optional, depending on whether or not you want to use an external hard drive or USB stick as storage for your torrent files. You don’t have to do this but without an external drive, all downloaded files would have to be stored on the SD card flashed with the OS. Since I’m also planning to use my server to stream media, I’m going to need a lot of permanent storage.

After formatting the hard drive to fat32 and plugging it into the pi, I installed a package for ntfs support in Raspbian and ran fdisk to find the hard drive. Once I had the hard drive address, I just needed the UID and GID of the user ‘pi‘ to add to the fstab file, which will automatically mount the drive to a folder I created called /media/hdd upon rebooting the pi. All of this was done as per the first half of this tutorial on creating a Raspberry pi NAS.

Installing Transmission

The first step was as simple as running sudo apt-get install transmission-daemon. Which, when put like that, might not sound so simple but trust me, it was. After making a few new folders for complete and in-progress torrents and giving the ‘pi’ user the appropriate permissions, the rest of the tutorial I used was just editing configuration files. One thing I did differently, however was disabling the whitelist, so I could access the Transmission interface from anywhere. This might cause a few security issues but, for my usage, this is fine until I find a workaround.

From there, the Transmission interface can be accessed from my local network via the static IP address I gave the pi earlier. To make the pi accessible from anywhere, I had to use port-forwarding to direct port 9091 to the pi’s IP. I’ve also forwarded ports 20 to 22 to use for SSH, FTP and other uses.

The tutorial was mostly great but there were a few problems I encountered affecting downloads, which were not included in the troubleshooting. Firstly, the downloads were halted due to ‘permission errors’, fixed by giving greater permissions to the transmission user over the affected folder(s). Fixing this caused a similar issue, where the interface said the storage device was full. Since I was using a newly formatted drive, the drive couldn’t be full. I was, however, using a 4GB SD card. Changing to a 32GB SD card, using ApplePi-Baker 2 to create a backup of the original card and burn it straight to the new card.

DLNA Streaming from the Pi with miniDLNA

This was the most surprisingly easy part of the process. MiniDLNA is installed with one line and only two lines of the configuration file need changing (as I found out in this tutorial), the friendly name and media directory. After that, any videos, music or pictures on the drive can be accessed from any DLNA/UPnP clients.

 

And that’s all there is to it! Four tutorials, a little extra on my part, a spare Hard drive from my PS4 and I’m downloading all sorts of things (legally from legitimate sources) from anywhere and streaming them across my home network!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s