Raspberry Pi as Torrent Client
tBOpq.png

We all download torrents. And some downloads take up a lot of time, which is a shear wastage of the electricity and processing power of the client computer just for the purpose of downloading. So in this article we tell you how to use Raspberry Pi for creating an always-on torrent handler which eliminates the need of a PC for torrent downloading.

Raspberry Pi

YlbMk.png

Raspberry Pi is a microprocessor which can perform almost all the function of a normal PC. What makes Raspberry Pi so popular is that it is very versatile and with a help of variety of supporting modules it can be used to create a variety of projects just like the one we are attempting to make.

Why to use Raspberry pi as torrent client?

  1. Raspberry Pi uses a very less power compare to a normal laptop or PC so it makes sense to use Raspberry Pi for downloads that take a very long time.
  2. Since the raspberry Pi is always on, one can monitor the cloud more and one can seed into it more which increases the seed ratio. Also if one is leeching from public trackers, an always on raspberry Pi ensures that one is able to download the rare files when they appear.
  3. It reduces the burden on your machine as allows you to do some other work, play a game on the system while your file is simultaneously downloading in the Pi
  4. The device is small and compact,so it can be kept anywhere and simply forgotten about,as long as the files download
  5. For those who don't have desktops,this is a very logical and economical alternative to keeping laptops on ,just for downloading torrent files
IMG_0621.JPG

Use R-Pi as torrent client

The below steps have been tried on our hardware and found to work with it, but may not work with certain hardware or circumstances, hence viewers are requested to follow steps only after fully understanding all of its consequences, to avoid any potential loss of data or damage.

Prerequisites

Hardware and Infrastructure

We need atleast (but not limited to) the following components for basic functioning of the torrent system:

  1. A working LAN setup with internet access
  2. A Raspberry Pi board (A 'B+' model is recommended for better performance)
  3. A computer (for remotely controlling the torrent client)
  4. An Ethernet Cable (for connecting the R-Pi to the LAN) (This is optional in case you want to connect the R-Pi using WiFi, but
  5. A USB to Mini-USB cable (for powering the R-Pi)
  6. A MicroSD card for R-Pi internal memory
  7. A USB compatible Flash storage device or HDD for storing downloads

The model of Raspberry Pi (B+) used by us has the following specifications :
- 700 MHz Broadcom BCM2835 CPU with 512MB RAM
- 40 pin extended GPIO
- 4 x USB2.0 Ports with up to 1.2A output
- MicroSD Storage
- HDMI , 3.5mm ports
- Ethernet port
- Mini-USB Power port

In addition to all the other features,it is better than it's lower version ( B ) in the following ways :
- Lower power consumption
- Better audio
- Smaller in size
- More USB ports
- MicroSD port instead of SC port,reducing effective size of the working device

Setting up R-Pi

  1. Download a Raspbian disk image. The Operating System used on the device is a Linux-Distribution by the name of 'Raspbian' (version Sept/14).
  2. Download a Image Disc Extraction Utility such as Win32 Disk Imager (for Windows) or ImageWriter (for Linux) to mount disk image.
  3. Insert the SD card and load the Raspbian Image on the Imaging software.
  4. Select the SD card drive and start the extraction. (Caution! SD card will be formatted, so any data should be backed up beforehand)
  5. Eject the SD card and insert it into R-Pi card slot.
  6. Connect a USB keyboard and a HDMI Output to R-Pi.
  7. Connect the power cable [USB switch cable] on to a power adapter or a Running PC's USB slot to power the R-Pi.
  8. At the config-window, select expand-rootfs (to expand the data storage to the whole SD card).
  9. Select SSH to start the SSH server.
  10. Select finish after doing any more changes if required. The Raspbian boots to a desktop.
  11. If using WiFi, set up WiFi access using WiFI config.
  12. Test the Internet by opening the browser.
  13. Open a terminal window and type the following:
sudo apt-get update && sudo apt-get upgrade

This will update the Raspbian firmware. Reboot to complete the setup.
The R-Pi is now working fine.

Installing VNC and testing SSH

It would be better if we can remotely control and monitor the R-Pi without using the extra keyboard and monitor. The utility we are using to achieve this is TightVNC. TightVNC is a free remote control software package. With TightVNC, we can see the desktop of a remote machine and control it with our local mouse and keyboard. To install:

sudo apt-get install tightvncserver
tightvncserver

This will install and start the TightVNC Server. You will be prompted to add a new password for remote access.
Now install TightVNC Viewer on your control PC. You can download the setup from here.
Now as the server is running, fire up the Viewer and input the IP address of the R-Pi to connect. Enter the password and the R-Pi screen shows up.


Now we will test the SSH connectivity.

  1. Open any SSH client (PuTTY for Windows) or a terminal window if it is on PATH.
  2. Enter the IP address of R-Pi and click connect/start the session.
  3. Enter the username and password to logon.
  4. Run any command and Use TightVNC to see if the changes reflect on the R-Pi. SSH is working too.

Installing Torrent Client

Now when we have a R-Pi with a remote terminal handy, we will now install a torrent client. The Client we are going to use is 'Deluge'. There are several torrent clients for Linux worth considering, but for our purposes we selected Deluge; it’s just the right balance of features and footprint so that we won’t find yourself wishing a month from now that we had installed a more powerful BitTorrent client.
So install Deluge from apt-get repository:

sudo apt-get install deluged
sudo apt-get install deluge-console

This will download the Deluge console and client. Now we need to run the daemon.
deluged
sudo pkill deluged

This will run the process and close it so that we can configure the process. The configurations file is /home/<USER>/.config/deluge/auth . We make a backup file and then open the file for editing.
cp ~/.config/deluge/auth ~/.config/deluge/auth.old
nano ~/.config/deluge/auth

At the bottom, there is a line with the following format:
user:password:level

Change the fields according to your wish. We have put 'pi' as user with password 'raspberry'. In level, you specify the level of authority, we will put that to 10 for our use.
Now start the process again.
deluged
deluge-console

We now enable the remote_access of Deluge using the following commands:
config -s allow_remote True
config allow_remote
exit

Now restart the server again for the changes to take effect. The Deluge daemon is now ready for remote access. Now we need to download the deluge torrent client for our control PC which is available here. Then run the deluge client and go to Edit->preferences->Interface and uncheck Classic mode to disable the default user interface. Click OK and restart the Deluge client. A dialog box titled Connections Manager opens. We need to add the remote connection, so we click 'add' and enter the R-Pi information. You will be redirected to the interface of R-Pi Deluge.


And the work is done.
You now just need to add torrents here and they will start downloading on the R-Pi.

Starting deluge on R-Pi boot

For the purpose, we use a script hosted on HowToGeek CDN for our disposal. We download the script.

sudo wget -O /etc/default/deluge-daemon http://cdn5.howtogeek.com/wp-content/uploads/gg/up/sshot5151a8c86fb85.txt
sudo nano /etc/default/deluge-daemon

In the script we change the username on the third line.
DELUGED_USER="pi"

Now we make the script executable and include it in the startup file.
sudo chmod 755 /etc/default/deluge-daemon
sudo update-rc.d deluge-daemon defaults

Now we download the real init.d file from HowToGeek CDN and also put that in the startup directory.
sudo wget -O /etc/init.d/deluge-daemon http://cdn5.howtogeek.com/wp-content/uploads/gg/up/sshot5151aa042ad11.txt
sudo chmod 755 /etc/init.d/deluge-daemon
sudo update-rc.d deluge-daemon defaults

So now we reboot the R-Pi and see if the Deluge ThinClient is working without any execution required on the R-Pi.

Configure the Download Directory

Since the SD-card is a limited memory, it will get filled up very quickly, so we need to route our downloads to a USB Flash Drive or HDD as a storage device. We make directories for files, torrents and other directories on our Storage device. Then we launch Deluge ThinClient and go to Preferences -> Downloads and set the directories there.

Additional Features

  1. The remote torrent client can be accessed on Android phones through the TransDrone app.
  2. Configure a Network File System for the R-Pi to transfer downloaded files over the LAN seamlessly.
  3. Putting Add-ons to our browsers for enhanced capability in case of Deluge WebUI.

Contributors

  1. Anshuman Suri (2014021) : R-Pi OS Install, Wiki Citations, Hardware, Wiki Text.
  2. Parikshit Diwan (2014074) : Presentation, Images, Scripts, Hardware.
  3. Rounaq Jhunjhunu Wala (2014089) : Installing Remote System, Network Configuration, Wiki Text

References

  1. http://www.raspberrypi.org/
  2. http://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/
  3. http://www.raspberrypi.org/forums/viewtopic.php?f=36&t=51219

Note: We do not, in any way, support downloading files illegally over the internet. There are some freely and legally available files on torrents as well,and for our project, we tested by downloading those files. We respect the copyrights and efforts of the developers in making the software. If you like the software after you pirate it, please buy it to support the developers to continue their work. #StopPiracy

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License