Setup raspberry pi as a torrent client using transmission


15 posts
by petrosl » Mon Jul 29, 2013 12:38 pm
Please before you start commenting about breaking the law etc etc notice that there are many freeware programs out there which you can download and share freely.
I never download and share movies, music etc.
Thank you

I’m not a LINUX expert so I spent some time trying to setup a torrent client with my Raspberry Pi. So I know how difficult it is and how much you have to search to set it up properly. This is the way I did it and it runs smoothly.
You can download all the instructions with pictures in this file http://db.tt/jqkO9c95

First of all these are the things you need to start your project

1. Your Raspberry Pi
2. A USB HUB with power
3. A USB hard disk

You need a keyboard to start which you can connect to the HUB
Now we have to go to our windows computer to format our USB Disk and prepare the SD Card.
I prefer to format my HDD to ext4 file system. It’s faster and more stable. For that I use the free Mini tool Partition Wizard. You can get it from here
http://download.cnet.com/MiniTool-Partition-Wizard-Home-Edition/3000-2094_4-10962200.html

To prepare the SD Card. To do that you need a program called Win32DiskImager and you can download it for free from
http://sourceforge.net/projects/win32diskimager/files/latest/download

Extract the exe an install it.

Then we have to download the Raspberry Pi distribution. I use the latest distribution from Pi’s official site. http://www.raspberrypi.org/downloads The image I use is the 2013-05-25-wheezy-raspbian
Extract the image file and start Win32DiskImager
Select your downloaded image, you SDCard device and press Write. Wait until the image is ready.

Now we are ready to start.

Put the SDCard to your Pi and put the power cable in. In this step toy need to have at list a keyboard connected to your HUB or your Pi and a monitor to see what’s happening. I use a Video cable and I connect it to my monitor
If you can’t connect it to your monitor you can move to your TV and plug the cable there so you don’t have to mess everything around. In this stage you don’t need the HUB and the disk.

Now you are ready to start.

First of all you have to setup your device to run the raspbian.

In the initial screen don’t forget to enable SSH. Also as you will use the Pi for torrenting you don’t need the GUI environment so choose to login into the console.
Finish all the proper adjustments and press finish.

Your device will restart and you have to log in. The defaults are
USER:pi PASSWORD:raspberry
If you have changed your password use the new password.
You are now logged in. Write down the address of your device so you can connect to it later. It is something like 192.168.1.24
Code: Select all
sudo shutdown –h now

and wait for the device to shut down.
At this point you can remove the keyboard and the monitor and connect the HDD and the HUB as above. Start the Pi and leave it there.

You can go now to your computer.

To connect to your pi’s console you need an SSH program. I use putty which you can download from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Run putty and write the address of your pi (in my case it is 192.168.1.24)
Log in the Pi using pi as user and your password
I have renamed my device as mypi the default name is raspberrypi

And now it is time to start. What I usually do is that I shutdown the pi and put the SD card back into the computer. I start Win32DiskImager and save my work to an image file (you can give to it any name) so if (better is when) I make a mistake I will not lose all my work.
If you press read the program copies the SD Card to an image file which you can write back later if necessary. (don’t forget to put .img at the end).

We are back logged in the pi.
[TIP] If you don’t like typing you can copy the text from windows and paste it to putty with a right click
First of all we need to update raspbian
Code: Select all
sudo apt-get update

Wait until the update is finished.

The next thing is to get rid of all the unnecessary GUI content
Code: Select all
sudo apt-get purge libx11-6 libgtk-3-common xkb-data lxde-icon-theme raspberrypi-artwork penguinspuzzle

[TIP] If you make a typing mistake you can press the UP ARROW and edit your command
Code: Select all
sudo apt-get autoremove

At this point system if very light. If you haven’t saved your work I think it’s time to do it now.

Next we must make our pi to have all times the same network address (static). For this we must use a text editor names nano to edit the file /etc/network/interfaces.
Code: Select all
sudo nano /etc/network/interfaces

We replace all the content of the file
Code: Select all
auto eth0
iface eth0 inet static
address 192.168.1.24
netmask 255.255.255.0
gateway 192.168.1.1

We do this when we are plugged into a wired network and we don’t use a wireless one, else we leave wla0 in place.
To write the content of the file to the SD we press Control-O [^O] and then ENTER. To exit nano [^X] (control and X simultaneously).
In the address toy can put at the fourth number any number between 2 and 255 but I prefer to use the address it was automatically assigned.
The gateway is usually 192.168.1.1. In my case it is 192.168.1.2 because of the router I use. In some cases might be 192.168.0.1 because the network address of the DHCP server (usually the router).
The gateway address is the address of your router which is connected to the internet.
If you change the address you better restart the pi.
If you want to have access from the internet, you should get an address from http://www.no-ip.org or any other provider. You'll also need to forward your external IP to your Pi's IP address on your LAN. It depends on your router. Usually there's NAT, or Virtual server or Port forward. Use port 80.

If you haven’t change the password of the Pi you can do it now
Code: Select all
sudo passwd

Now it’s time to see our partition table.
Code: Select all
cat /proc/partitions

Our disk is sda1.

We need to instruct Pi to mount our Disk at the same position
Code: Select all
sudo mkdir /media/USBDisk

Before we can mount the drives, we need to create a directory to mount the drives to.
Code: Select all
sudo mount -t auto /dev/sda1 /media/USBDisk

*Note that in LINUX words are case sensitive. USBDisk is not the same as usbdisk
Code: Select all
sudo mkdir /media/USBDisk/shares
sudo mkdir /media/USBDisk/shares/downloading
sudo mkdir /media/USBDisk/shares/completed

Code: Select all
sudo nano /etc/fstab

We add the /dev/sda1 line and save it
Code: Select all
/dev/sda1 /media/USBDisk ext4 defaults,noatime 0 0

NOW it’s time to install the torrent client. There are quite a few I have used transmission and deluge. I prefer transmission because I can easily control it from my android phone and my work computer. Later we will show toy how to install deluge
Code: Select all
sudo apt-get install transmission-daemon

Let’s configure the permissions now
Code: Select all
sudo usermod -a -G debian-transmission pi
sudo chgrp debian-transmission /media/USBDisk/shares/downloading
sudo chgrp debian-transmission /media/ USBDisk/shares/completed
sudo chmod 770 /media/USBDisk/shares/downloading
sudo chmod 777 /media/ USBDisk/shares/completed

The permissions let us browse read and write to the completed directory but we can’t browse the downloading one. If you want you can change the 770 to 777 to have full control on it.

Reload the transmission
Code: Select all
sudo service transmission-daemon reload

Edit transmission settings.json file
Code: Select all
sudo nano /etc/transmission-daemon/settings.json

The content of the file is here. Marked are the lines we must edit
{
"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": "/media/data/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": "/media/data/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
}

"download-dir": "/media/data/complete", becomes "download-dir": "/media/USBDisk/shares/completed",
"incomplete-dir": "/media/data/incomplete", becomes "incomplete-dir": "/media/USBDisk/shares/downloading",
"rpc-username": "transmission", becomes "rpc-username": "myname",

I changed the username because it’s easier to remember. You are not obliged to do that if you don’t want to.
Cross your fingers and open your browser

And now it’s time to install SAMBA
Code: Select all
sudo apt-get install samba samba-common-bin

Open the configuration file
Code: Select all
sudo nano /etc/samba/smb.conf

At the end of the file add the following lines
Code: Select all
[Torrentbox]
comment = Public Shares
path = /media/USBDisk/shares/completed
writeable = Yes
only guest = Yes
create mask = 0777
directory mask = 0777
browseable = Yes
public = yes

Restart SAMBA
Code: Select all
 sudo service samba restart


THAT’S IT
YOU CAN NOW ACCESS YOUR FILES FROM WINDOWS EXPLORER
If you want to access transmission from your android phone you can install Remote Transmission

Hope I helped

NOTE. I face no problems with transmissions stability but other users do, Efstathios Iosifidis made the following changes and he found that they work OK.

Edit /boot/cmdline.txt and add “smsc95xx.turbo_mode=N” to it.
Edit /etc/sysctl.conf and change “vm.min_free_kbytes =16384″ (from 8MB to 16MB).

If you want to have access to your files from outside you have to install an ftp server. This is how we can do it.

Install the ftp program
Code: Select all
sudo apt-get install vsftpd

Uncomment (that means delete the # before) the following lines
Code: Select all
local_enable=YES
write_enable=YES

Restart the service and you are done
Code: Select all
sudo service vsftpd restart
Posts: 4
Joined: Mon Jul 29, 2013 8:47 am
by pilotguy » Sat Dec 07, 2013 7:06 pm
Thanks for this. This really helped me a lot!
512 mb Model B Rev 2, 16Gb class 6 SD card. Raspbian 2013-05-25.
Power mac G4 1.25 Ghz
Lenovo G505
Macbook4,1
HP desktop running Ubuntu
Posts: 28
Joined: Tue Jan 01, 2013 4:52 am
Location: Canada
by pimonatic » Sat Mar 22, 2014 6:06 pm
The installation worked well and I indead did strictly follow your instructions, but while downloading I always run into the "No space left on device"-error.
Where Transmission thinks the device is just the size of the SD-partition not the USB-Drive/Stick.
I'm using a 32GB USB2.0 stick. How do I get Transmission to recognize it's size instead of running into the no space left-error?
The files I'm downloading are stored on that mounted stick and not in the default folders, nor are the incomplete ones stored on the SD-card as well.

So, where's the wrong size recognition coming from?
Posts: 3
Joined: Sat Mar 22, 2014 5:51 pm
by petrosl » Sat Mar 22, 2014 6:32 pm
What size are the files you are downloading? If they are more than 2GB you must format your media as ext4 or NTFS and not as FAT32.
Posts: 4
Joined: Mon Jul 29, 2013 8:47 am
by pimonatic » Sat Mar 22, 2014 6:55 pm
They 400 - 500 MB, the whole has torrent is 28GB. It's getting that message at ~941MB, The space left on the sd-cart before starting the torrent. maybe it's a driver fault or mount fault?
Oh, and the filesystem is ext4 indeed. Formatted with GParted on LinuxMint.
Posts: 3
Joined: Sat Mar 22, 2014 5:51 pm
by petrosl » Sun Mar 23, 2014 7:39 am
The files are stored in the USB drive which must be connected when you setup the transmission. If the torrents are stored in the SD card it means that the program can't find the directories.
Posts: 4
Joined: Mon Jul 29, 2013 8:47 am
by pimonatic » Sun Mar 23, 2014 10:54 am
It is connected and the files ARE stored on the USB-device, none are anywhere on the SD-card.
It's a riddle, I think it may be something with mount. (Or maybe incompatibility with the stick? It's MSN is 5004 6666 and EAN is 2904 8984)

EDIT: Attempting to retry the whole installation process and config. Maybe there's some bit at the wrong side.
Posts: 3
Joined: Sat Mar 22, 2014 5:51 pm
by petrosl » Mon Mar 24, 2014 6:38 am
Good luck :D
Posts: 4
Joined: Mon Jul 29, 2013 8:47 am
by joesse » Mon Mar 31, 2014 7:34 am
Thanks for this tutorial.
I want transmission to save it's downloads on a samba share. So in /etc/fstab I have
Code: Select all
//192.168.13.4/public/completed /mnt/smb/public/completed cifs users,guest,uid=pi,gid=debian-transmission,_netdev
//192.168.13.4/public/downloading /mnt/smb/public/downloading cifs users,guest,uid=pi,gid=debian-transmission,_netdev

Mounting these shares seems to work.
Code: Select all
pi@proxypi ~ $ ls -l /mnt/smb/public/
insgesamt 0
drwxrwxrwx 2 pi debian-transmission 0 Mär 30 13:29 completed
drwxrwx--- 3 pi debian-transmission 0 Mär 31 08:40 downloading
pi@proxypi ~ $ mkdir /mnt/smb/public/completed/testdir
pi@proxypi ~ $ ls -l /mnt/smb/public/completed/
insgesamt 0
drwxr-xr-x 2 pi debian-transmission 0 Mär 31 09:27 testdir

But still I get an error in transmission:
Error: Permission denied (/mnt/smb/public/completed/openSUSE-13.1-DVD-x86_64.iso/openSUSE-13.1-DVD-x86_64.iso)

Any idea what is still to be fixed?
User avatar
Posts: 2
Joined: Mon Mar 31, 2014 7:21 am
by joesse » Mon Mar 31, 2014 9:21 am
Forget my last post; I found it myself. fstab must be:
Code: Select all
//192.168.13.4/public/completed /mnt/smb/public/completed cifs users,guest,uid=debian-transmission,gid=debian-transmission,_netdev
//192.168.13.4/public/downloading /mnt/smb/public/downloading cifs users,guest,uid=debian-transmission,gid=debian-transmission,_netdev
User avatar
Posts: 2
Joined: Mon Mar 31, 2014 7:21 am
by speedysloth » Wed Apr 02, 2014 6:20 pm
Let’s configure the permissions now
Code: Select all
sudo usermod -a -G debian-transmission pi
sudo chgrp debian-transmission /media/USBDisk/shares/downloading
sudo chgrp debian-transmission /media/ USBDisk/shares/completed
sudo chmod 770 /media/USBDisk/shares/downloading
sudo chmod 777 /media/ USBDisk/shares/completed

The permissions let us browse read and write to the completed directory but we can’t browse the downloading one. If you want you can change the 770 to 777 to have full control on it.


What extra steps would I take to also allow the samba share to share the WHOLE usb drive, not just the download folders?
Posts: 11
Joined: Wed Apr 02, 2014 6:16 pm
by bharathyes » Thu Sep 18, 2014 6:05 am
Hi,
I followed this tutorial and have been using this for a couple of weeks. It was working fine till yesterday.
I deleted some incomplete torrents because I ran out of space. But the memory wasn't released, so I formatted the USB drive and tried to apply the permissions after creating all the folders in the drive. But I am unable to do so.
Code: Select all
sudo usermod -a -G debian-transmission pi
sudo chgrp debian-transmission /media/USBDisk/shares/downloading
sudo chgrp debian-transmission /media/ USBDisk/shares/completed
sudo chmod 770 /media/USBDisk/shares/downloading
sudo chmod 777 /media/ USBDisk/shares/completed

In this the second and third commands throw the following error.
chgrp: changing group of `/media/USBDisk/shares/downloading': Operation not permitted


Now, even though I am able to start a torrent, it stops after downloading a couple of MBs of data with the error
Persmission Denied.


Can someone help me with this. Thanks in advance.

P.S.: Great tutorial by the way. Really awesome.
Posts: 5
Joined: Sat Jul 26, 2014 2:25 pm
by jhaprade » Thu Feb 19, 2015 12:09 am
I am getting exactly the same error. Did you figure out a way around?
Posts: 3
Joined: Wed Feb 18, 2015 9:01 pm
by davboc » Tue Feb 24, 2015 1:04 am
If I use a SD card with much space, I can select this sd as download path?

Thanks for this beautiful guide!
Posts: 31
Joined: Mon Feb 23, 2015 10:45 pm
by killerme » Sun Nov 29, 2015 10:37 am
This is a fairly old topic but to clear up - the problem of SD cards listed above is probably because cheap (ebay purchased) SD cards seldom have the real size as listed. Download 'H2testW' which will tell you the actual size of your card to be sure. I have downloaded 32 GB cards only to find out the barely contain 1 gb!
Posts: 2
Joined: Sun Nov 29, 2015 10:31 am