3069 views 0 comments

Project #3: Create a PirateBox (BitTorrent) | Raspberry Pi 2

by on March 29, 2016
 

Hello Folks,

It’s been a while since I posted a new Raspberry Pi project. Well, to be honest, I got busy with a few new gaming titles and was in a quest to finish them. Now that I am back to DIY mind, I will be sharing how can we create an always on BitTorrent PirateBox (pirate for name sake) 😛

Despite my rant in past about how BitTorrent as we know it is dying, We all love torrents (legit or not). But most of the times when one wants to download a huge OS Live disc image like Ubuntu Server or maybe even Kali Linux when size is in a couple of Gigabytes, we have to leave a PC/Laptop switched on overnight for it to complete. We all do it, I am sure you can relate to it.

But what if I tell you that you can make an always running Torrent box which will work 24/7 and download all the stuff in your network attached storage for you to get and stream? All that by just using your good old trust Raspberry Pi. Too good to be true huh?

What is a PirateBox?

Well, a Raspberry Pi Torrent Box, or as I like to call it, Piratebox, is a great way to have a cheap affordable always on torrent machine. Doesn’t matter whether you’re a heavy or light torrent user, it still works pretty well for both! It is your automated torrent downloading solution which will use a negligible amount of electricity and will require no attention when once setup. You can access it from anywhere and add more stuff to download anytime (Yes! Even when you are en route to work).

What do I need?

Let’s begin!

I am assuming you are all setup with OS installation and logged in to the shell (terminal).

Bittorrent always on pirate box with Raspberry Pi 2

The setup.

Step #1: Update ‘n’ Upgrade?!

Update your software repositories and upgrade the existing software(s) using the following command(s):

sudo apt-get update

sudo apt-get upgrade

 SSH VNC and update apt-get - PirateBox via Raspberry Pi 2

VNC is optional

apt-get upgrade - PirateBox via Raspberry Pi 2

Updating/Upgrading

Step #2: Installing Transmission daemon

Transmission – A native multi-platform BitTorrent client

sudo apt-get install transmission-daemon

3. install transmission daemon - PirateBox via Raspberry Pi 2

Installing Transmission-daemon

Step #3: Mount your network attached storage

Project NAS – Read here to configure.

Also, create 2 directories on your storage via

sudo mkdir -p /media/PirateBox/downloading

sudo mkdir -p /media/PirateBox/completed

These directories will act as suggested by their names. Downloading will contain the incomplete files and Completed will have the downloaded files.

 Adding PirateBox to NAS for easier access - PirateBox via Raspberry Pi 2

Setting the Piratebox path

Mounting storage and creating download directories - PirateBox via Raspberry Pi 2

Mount your network attached storage

Step #4: Configure your Transmission settings

After the storage is set up, we will configure the Transmission daemon. First, open the settings.json file in nano using the command:

sudo nano /etc/transmission-daemon/settings.json

Modifying Transmission settings configuration - PirateBox via Raspberry Pi 2

Configuring Transmission daemon

I recommended making the following changes but there are other settings you may want to update depending on your preference. You can also change other flags, to read about them click here.

You can set the rpc-username and rpc-password as per your liking. It will be used to authenticate the user so not everyone can see your torrent(s) and stuff. 😉

Make sure you add your local IP address pool to rpc-whitelist. It will prevent devices not on your network to use the PirateBox.

Step #5: Reload the transmission-daemon to apply changes

sudo service transmission-daemon reload

Reloading the transmission-daemon to apply settings - PirateBox via Raspberry Pi 2

Reload

Note: Remember to not restart the service as it will factory restore the default configuration.

Step #6: Time to set up some permissions, configuration and a user.

We need to set up some configurations to make sure that transmission runs as the correct user. If we don’t do the steps below, we will run into lots of errors.

First, let’s stop the transmission service by entering the following command:

sudo service transmission-daemon stop

7. Stop transmission to create a user to download torrents

Stop! Time for some serious stuff.

Now we need to edit the daemon so it launches as the user who owns the directory we wish to store in. Let’s open the file by entering the following command:

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

To check who owns the folder use ls -l /media/PirateBox/downloading

In the daemon configuration here, edit the user so it runs as the user who owns the directory we’re storing our downloads in. In my case, it is pi instead of the default debian-transmission. We need do this because the folder we are going to store our torrents is likely to be owned by a different user than the default transmission.

USER=pi

8. Setting user for Transmission

User access.

After we set up the user, we need to give read/write permissions to the same user for the following directories via command(s):

sudo chown -R pi:pi /etc/transmission-daemon

sudo chown -R pi:pi /etc/init.d/transmission-daemon

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

9. Giving permission to pi user to access the transmission settings

Owning the directories

This is an important step, do not skip it else you won’t be able to launch transmission-daemon and download stuff.

After setting the required permissions and the user, now it’s time to start the transmission-daemon:

sudo service transmission-daemon start

10. Starting back the transmision-daemon

Kickstarting it back up!

Step 7: Profit!

So, now to see all the action, just put the IP address or hostname.local of your RasPi in your web browser and voila!

To get your IP address on local server, use command:

hostname -I

 Get your IP address on local network - - PirateBox via Raspberry Pi 2

Your IP address on network

Put that in a web browser and you will be greeted with a login alert. Enter the rpc-username & rpc-password we configured in step #4.

Accessing the web ui of transmission by giving the url-port - PirateBox via Raspberry Pi 2

Log me in!

Note that, I am running the transmission-daemon on port 9999 since I modified the default in the configuration. The default port is 9091.

We can use both .torrent file or magnet URL to add torrent. Let’s see how we can download Ubuntu iso via BitTorrent below:


So, this is how we do it. You now have an always running low powered BitTorrent machine aka PirateBox at your disposal (it’s cooler this way). 😉

Let us know how was your experience building this project. Also, do share how much you were able to utilize your ISP’s poor post FUP bandwidth? Here’s my personal record for reference, Good luck! 😎

MTNL broadband usage - PirateBox via Raspberry Pi 2

Well..

Be the first to comment!
 
Leave a reply »

 

Leave a Response