Friday, November 16, 2012

Installing, Configuring and Using Raspberry Pi as a Torrent Downloading Server

BitTorrent is without a doubt the most popular file-sharing method out there, Peer-2-Peer (P2P) torrent downloading requires a computer which runs a torrent downloading client to fetch content from other users sharing it. Torrent downloading can be slow as speeds depends on swarm sharing the content, this means you need to have your computer powered-on consuming electricity. Luckily, we can now use our ultra-cheap Raspberry Pi to get the job done 24x7 - consuming just 5w of power.
After completing the basic setup of the Raspberry Pi, networking it to internet, attaching an external HDD and configuring it to work as an Network Attached Storage (NAS) we all all set to install the cross-platform Transmission Torrent Client of the RasPi to get our cheap seedbox working.
Transmission torrent cleint web-interface from Raspberry Pi
Steps to install and configure Transmission on Raspberry Pi :
  1. Install Transmission using sudo apt-get install transmission-daemon.
  2. Create folders for downloading content : mkdir -p /home/pi/incomplete # for incomplete downloads
    mkdir /home/pi/complete # finished downloads
  3. Configure proper permissions for transmission :
    sudo usermod -a -G debian-transmission pi
    chgrp debian-transmission /home/pi/incomplete
    chgrp debian-transmission /home/pi/complete
    chmod 770 /home/pi/incomplete
    chmod 770 /home/pi/complete

  4. Now, reload transmission daemon - sudo service transmission-daemon reload
  5. Edit transmission settings.json file using sudo nano /etc/transmission-daemon/settings.json and use following settings.

  6. {
    "alt-speed-down": 50,
    "alt-speed-enabled": false,
    "alt-speed-time-begin": 540,
    "alt-speed-time-day": 127,
    "alt-speed-time-enabled": false,
    "alt-speed-time-end": 1020,
    "alt-speed-up": 50,
    "bind-address-ipv4": "0.0.0.0",
    "bind-address-ipv6": "::",
    "blocklist-enabled": false,
    "blocklist-url": "http://www.example.com/blocklist",
    "cache-size-mb": 4,
    "dht-enabled": false,
    "download-dir": "/home/pi/complete",
    "download-limit": 100,
    "download-limit-enabled": 0,
    "download-queue-enabled": true,
    "download-queue-size": 5,
    "encryption": 1,
    "idle-seeding-limit": 30,
    "idle-seeding-limit-enabled": false,
    "incomplete-dir": "/home/pi/incomplete",
    "incomplete-dir-enabled": true,
    "lpd-enabled": false,
    "max-peers-global": 200,
    "message-level": 2,
    "peer-congestion-algorithm": "",
    "peer-limit-global": 91,
    "peer-limit-per-torrent": 150,
    "peer-port": 51413,
    "peer-port-random-high": 65535,
    "peer-port-random-low": 49152,
    "peer-port-random-on-start": false,
    "peer-socket-tos": "default",
    "pex-enabled": false,
    "port-forwarding-enabled": true,
    "preallocation": 1,
    "prefetch-enabled": 1,
    "queue-stalled-enabled": true,
    "queue-stalled-minutes": 30,
    "ratio-limit": 2,
    "ratio-limit-enabled": false,
    "rename-partial-files": true,
    "rpc-authentication-required": true,
    "rpc-bind-address": "0.0.0.0",
    "rpc-enabled": true,
    "rpc-password": "{2dc2c41724aab07ccc301e97f56360cb35f8ba1fGVVrdHDX",
    "rpc-port": 9091,
    "rpc-url": "/transmission/",
    "rpc-username": "transmission",
    "rpc-whitelist": "*.*.*.*",
    "rpc-whitelist-enabled": false,
    "scrape-paused-torrents-enabled": true,
    "script-torrent-done-enabled": false,
    "script-torrent-done-filename": "",
    "seed-queue-enabled": false,
    "seed-queue-size": 10,
    "speed-limit-down": 250,
    "speed-limit-down-enabled": true,
    "speed-limit-up": 0,
    "speed-limit-up-enabled": true,
    "start-added-torrents": true,
    "trash-original-torrent-files": false,
    "umask": 18,
    "upload-limit": 100,
    "upload-limit-enabled": 0,
    "upload-slots-per-torrent": 14,
    "utp-enabled": true
    }


  7. After saving the settings, reload and restart transmission daemon.
    sudo service transmission-daemon reload
    sudo service transmission-daemon restart

  8. You are all set to access the web-interface to control your Transmission client remotely, just point your web-browser to http://RASPI.IP.ADDRESS:9091/ and use the login/password (default for above config transmission/transmission) combination inside settings.json to login.
  9. My router supports DynamicDNS (DDNS) and it can be used to control your torrent client from anywhere in the world over internet (as shown in image above).
This setup worked fine for some time but resulted in frequent hangs if left running for longer periods. To solve the RaspberryPi Kernel panic issue when using transmission downloading make the following changes and reboot your RasPi :
  1. Edit /boot/cmdline.txt and add “smsc95xx.turbo_mode=N” to it.
  2. Edit /etc/sysctl.conf and change “vm.min_free_kbytes =16384″ (from 8MB to 16MB).
Once torrents are downloaded, they can be accessed over the network via a Samba share. Make sure to create a new public share to your transmission completed download directory (/home/pi/complete) using the instructions provided earlier and have it accessed easily from the RasPI NAS.

No comments:

Post a Comment