By popular demand I’ll go through all the steps to get a bittorrent client running on the WDTV. My client of choice is rtorrent so that is what I’m going to cover. rtorrent is an extremely fast and lightweight client so it suits the wdtv perfectly. You’ll be downloading torrents in no time flat.
In order to take advantage of this tutorial you must either be running WDLXTV or Zoranders ext3-boot. You must also have my Optware for WDTV package installed, that stuff is covered elsewhere. I’ll be including every necessary step here, so you might be able to skip around if you already have some of this done.
So first ssh/telnet into your WDTV.
Next we’ll update our Optware feed and install rtorrent & screen.
# ipkg update
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//Packages.gz
Inflating http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//Packages.gz
Updated list of available packages in /opt/lib/ipkg/lists/wdtv
Successfully terminated.
#
# ipkg install rtorrent screen
Installing rtorrent (0.8.2-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//rtorrent_0.8.2-1_mipsel.ipk
package rtorrent suggests installing dtach
package rtorrent suggests installing adduser
Installing libtorrent (0.12.4-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//libtorrent_0.12.4-1_mipsel.ipk
Installing screen (4.0.3-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//screen_4.0.3-2_mipsel.ipk
Installing termcap (1.3.1-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//termcap_1.3.1-2_mipsel.ipk
Installing libsigc++ (2.0.18-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//libsigc++_2.0.18-1_mipsel.ipk
Installing libcurl (7.19.4-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//libcurl_7.19.4-1_mipsel.ipk
Installing xmlrpc-c (1.11.00-3) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//xmlrpc-c_1.11.00-3_mipsel.ipk
Installing libxml2 (2.7.3-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//libxml2_2.7.3-1_mipsel.ipk
Installing libiconv (1.11-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//libiconv_1.11-2_mipsel.ipk
Configuring libcurl
Configuring libiconv
Configuring screen
Configuring termcap
Configuring libsigc++
Configuring libtorrent
Configuring libxml2
Configuring rtorrent
Configuring xmlrpc-c
Successfully terminated.
Lets see what comes up in a search for rtorrent.
# find /opt/* | grep rtorrent
/opt/bin/rtorrent
/opt/etc/rtorrent.conf
/opt/etc/init.d/S99rtorrent
/opt/lib/ipkg/info/rtorrent.control
/opt/lib/ipkg/info/rtorrent.conffiles
/opt/lib/ipkg/info/rtorrent.list
/opt/share/man/man1/rtorrent.1
There are two important files to point out here: /opt/etc/rtorrent.conf and /opt/etc/init.d/S99rtorrent
/opt/etc/init.d/S99rtorrent is a startup script that will be executed every single time you start your wdtv. Yes, this means after you make it through this painful tutorial you won’t have to mess with the console again and can just ftp torrents in.
/opt/etc/rtorrent.conf is what we want to immediately deal with. This is the configuration file, open it with your favorite text editor. I’m using nano. At the top of the file change min/max peers and upload/download rate to whatever suits your connection. If you don’t know what would be good, maybe just modify these two:
# Global download rate in KiB. "0" for unlimited.
download_rate = 80
# Global upload rate in KiB. "0" for unlimited.
upload_rate = 80
Setting download rate to zero makes it unlimited, change upload_rate to whatever suits your connection. The default is 80, maybe a bit high for lots of folks. Remember the speed you choose here will affect being able to play high bandwidth material off your network shares! * see note below *
Next we need to select the directory where we’d like to save downloaded file and where we want our *.torrent watch directory to be. The default directory is inside your opt.bin, so unless you’ve made that ginormous you best change this.
Note: For various reasons I keep my active torrent hard drives seperate from data storage drives and I’ll be doing that here as well. Especially on the WDTV you’re best having your torrents download to a drive without much media so as to not have disk I/O interfere with watching movies, listening to music, etc.
# Default directory to save downloaded files. Note it doesn't support
# space yet.
directory = /tmp/media/usb/torrent-disk/
# Watch a directory for new torrents, and stop those that have been deleted.
schedule = watch_directory,5,5,load_start=/tmp/media/usb/torrentdisk/torrent-drop/*.torrent
schedule = untied_directory,5,5,stop_untied=
You’ll probably need to set up port forwarding, so make port_range your favourite number and set your router up later.
# Port range to use for listening.
port_range = 51777-51780
Default seed ratio is 200%, I’ll lower that to 110%.
# Stop torrents when reaching upload ratio in percent,
# when also reaching total upload in bytes, or when
# reaching final upload ratio in percent.
# example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0
#schedule = ratio,60,60,"stop_on_ratio=200,200M,2000"
schedule = ratio,30,60,stop_on_ratio=110
If DHT and peer exchange are your thing, then remove the # from the beginning of these lines.
# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
# dht = auto
# UDP port to use for DHT.
# dht_port = 6881
# Enable peer exchange (for torrents not marked private)
# peer_exchange = yes
Ok, thats it. Now to see if it works.
# rtorrent
*** rTorrent 0.8.2/0.12.4 - wdtv-01:2633 ***
[View: main]
(21:09:09) Using 'select' based polling.
(21:09:09) Could not read resource file: ~/.rtorrent.rc
[Throttle off/off KB] [ .......... ] [H 0/32] [S 0/1/768] [F 0/128]
no, it does not. This is a good time to mention how you exit rtorrent, Ctrl^q. This means when we start rtorrent we have to point it to /opt/etc/rtorrent.conf.
# screen rtorrent -n -o import=/opt/etc/rtorrent.conf
rtorrent: Could not lock session directory: "/opt/share/torrent/session/", No such file or directory
[screen is terminating]
# mkdir -p /opt/share/torrent/session
The session directory doesn’t exist, so I create it. Now it should work.
# screen rtorrent -n -o import=/opt/etc/rtorrent.conf
*** rTorrent 0.8.2/0.12.4 - wdtv-01:2850 ***
[View: main]
(21:22:08) Using 'select' based polling.
(21:22:08) Ignoring ~/.rtorrent.rc.
[Throttle 200/off KB] [ ... ] [D 0/0] [H 0/32] [S 0/2/768] [F 0/128]
[screen is terminating]
#
Perfect, so now everything looks like it will work I’ll:
- start up rtorrent under screen, so that it may be detached to the background.
- Once inside rtorrent, press Ctrl^ad (press ctrl, then a, then d) to detach
- Move a torrent into the watch directory that was setup.
- resume rtorrent and watch torrent go.
- detach rtorrent and watch a movie:D
Here we go:
# screen rtorrent -n -o import=/opt/etc/rtorrent.conf
*** rTorrent 0.8.2/0.12.4 - wdtv-01:2960 ***
[View: main]
(21:28:43) Using 'select' based polling.
(21:28:43) Ignoring ~/.rtorrent.rc.
[Throttle 200/off KB] [ ... ] [D 0/0] [H 0/32] [S 0/2/768] [F 0/128]
[screen detached]
#
# mv /tmp/something.torrent /tmp/media/usb/sda2/torrent-drop
# screen -r
*** rTorrent 0.8.2/0.12.4 - wdtv-01:3159 ***
[View: main]
something 10.0 / 712.0 MB Rate: 10.0 / 934.2 KB Uploaded: ......
Tracker[0:0]: Connecting to some tracker
[Throttle 200/off KB] [ ... ] [D 36/0] [H 0/32] [S 0/38/768] [F 52/128]
[detached]
#
# exit
Awesome.
Keys you should be aware of:
- a / s / d raise upload speed limit 1 / 5 / 50 KiB
- z / x / c lower upload rate limit 1 / 5 / 50 KiB
- A / S / D raise download rate limit 1 / 5 / 50 KiB
- Z / X / C lower download rate limit 1 / 5 / 50 KiB
- Ctrl^s starts a torrent
- Ctrl^d stops a started torrent or removes a stopped torrent
- number 1 – 9 are different views (all / started / stopped / seeding / etc )
- use the arrow keys to navigate around.
- Ctrl^ad detaches rtorrent to the background
- screen -r resumes rtorrent
- Ctrl^q exits rtorrent
Note: my WDTV is fairly unresponsive with rtorrent zipping at the settings i chose, which was 200KiB up and unlimited down. I imagine the disk I/O just made my WDTV have a coronary. So maybe you should lower the default max_upload and stick with default max_download values, and experiment raising/lowering them until you find a nice value. I gotta wait 10min till what I started is done to see if my WDTV happens to wake back up
Well now i know.
Soon I’ll look into modifying rtorrents priority with nice to set it at idle, and play with a bit of the config settings to see if they’ll help things out. So be sure to check back here for and update.
Also look out for part 2 of this tutorial soon, where I’ll detail setting up the best rtorrent interface: wtorrent. Then you’ll never have to go to the console again!
Note: In case you’ve forgotten by now, rtorrent will be started whenever you boot your wdtv. This means you do not start it up if you ssh/telnet in and want you check out your torrents. You simply type:
# screen -r
Enjoy!
EDIT
my WDTV did not recover from my snafu above
BUT i changed the settings to max_upload=50 max_download=300 and its downloading fine. In fact no problems as I play a local 1080p mkv, while i view rtorrent downloading and hash checking in a remote shell
Remember the speed you choose here will affect being able to play high bandwidth material off your network shares!
Note:
/opt/etc/init.d/S99rtorrent contains syntax errors so it does not start rtorrent when you boot your wdtv, i’ll look into fixing that soon and provide a patched version.