Low Overhead Console Based Torrent Client – rTorrent

Having used Java based torrent clients on older/embedded hardware (1GHz VIA processors) I have seen CPU utilisation saturate and systems grind to a halt. It is not practical to run GUIs or heavily emulated applications on these types of processors. Lets remember that in reality 1GHz is not all that slow, and coupled with plenty of RAM that processor makes an effective console server box without a clunky GUI to slow it down.
I am running CentOS 5.4 and came across rTorrent. As much as I love Linux, as usual there was something stopping the installation working out the box. The system pre-installed libcurl was causing rTorrent to timeout on its connections. This is a documented bug.

I was left with no choice but to build rTorrent and link it against custom libraries that it is compatible with. However I also needed to preserve the original version as the system libraries were linked against the older version. After lots of posts, environment variable fudges and hacks, finally a fellow Linux users helped out: http://markus.revti.com/2009/12/install-rtorrent-using-curl-in-different-path-on-centos-linux/

To group everything in one place I have put the steps below (again all credits to Markus for the help).

Additional Repos

First I setup sourceforge repositories and updated the system

wget http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm
rpm -i rpmforge-release-0.3.6-1.el5.rf.*.rpm
yum update


yum install gcc gcc-c++ m4 make automake libtool pkgconfig perl openssl-devel ncurses-develwget http://curl.haxx.se/download/curl-7.19.7.tar.gz
wget http://ftp.gnome.org/pub/GNOME/sources/libsigc++/2.2/libsigc++-2.2.4.tar.gz
wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.12.5.tar.gz
wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.8.5.tar.gztar -xvzf curl-7.19.7.tar.gz
tar -xvzf libsigc++-2.2.4.tar.gz
tar -xvzf libtorrent-0.12.5.tar.gz
tar -xvzf rtorrent-0.8.5.tar.gzCompile Curl in /opt/curl-7.19.7


cd curl-7.19.7
./configure –prefix=/opt/curl-7.19.7
make install


Compile libsigc++ in /opt/libsigc-2.2.4

cd libsigc++-2.2.4
./configure –prefix=/opt/libsigc-2.2.4
make install


Compile libtorrent

cd libtorrent-0.12.5
rm -f scripts/{libtool,lt*}.m4
make install


To compile rTorrent we need to include the path to the libtorrent librarys as installed in the previous step.export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig cd rtorrent-0.8.5
rm -f scripts/{libtool,lt*}.m4
./configure libcurl_CFLAGS=-I/opt/curl-7.19.7/include libcurl_LIBS=’-L/opt/curl-7.19.7/lib -lcurl -L/usr/kerberos/lib -lssl -lcrypto -lrt -lssl -lcrypto -ldl -lz -lz’
make install


The init.d scripts on the rtorrent wiki did not work for me (or broke at some point after reboot), after removing the redirection from the default script I saw the error “No screen session found.”  After digging around on the net came across another script that resolved this (apparently screen wasn’t running before the init.d script was called). I then added chkconfig lines and got the following config below:

# Comments to support chkconfig on RedHat Linux
# chkconfig: 345 85 15
# description: rtorrent – BitTorrent Client
# This script depends on screen.
# For the stop function to work, you must set an explicit session directory using absolute paths (no, ~ is not absolute) in your rtorrent.rc.
# If you typically just start rtorrent with just "rtorrent" on the command line, all you need to change is the "user" option. Attach to the
# screen session as your user with # "screen -dr rtorrent". Change "rtorrent" with srnname option. Licensed under the GPLv2 by lostnihilist:
# lostnihilist _at_ gmail _dot_ com

##Start Configuration##
#Do not put a space on either side of the equal signs e.g.

# system user to run as # not implemented, see d_start for beginning implementation
group=$(id -ng "$user")

# default directory for screen, needs to be an absolute path
base=$(su -c ‘echo $HOME’ $user)

# name of screen session

# file to log to (makes for easier debugging if something goes wrong)


case "$1" in
    echo "Starting $DESC: $NAME"
    [ -d "${base}" ] && cd "${base}"
    stty stop undef && stty start undef
    su $user -c ‘screen -d -m rtorrent’ &> /dev/null
    if [ $? -gt 0 ]; then
      echo "Failed to start $DESC: $NAME"
      echo "Started $DESC: $NAME"
    echo "Stopping $DESC: $NAME"
    killall -w -s 2 rtorrent &> /dev/null
    screen -wipe
    if [ $? -gt 0 ]; then
      echo "Failed to stop $DESC: $NAME"
      echo -n "Stopped $DESC: $NAME"
    $0 stop
    sleep 1
    $0 start
    echo "usage: $0 {start|stop|restart|force-reload}"
exit 0


Finally got Samba to enable pulling of files off the box, and to upload files to the watch directory so rtorrent would auto-start them.

yum install cups-libs samba samba-common
chkconfig smb on

And then edited the config file:

vi /etc/samba/smb.conf

        comment = Home Directories
        browseable = no
        writable = yes
        valid users = %S

Now downloading at nearly 900kB/sec with no more than 10% CPU utilisation (compared to 75% before at 120kB/sec with one particular Java based client I know!).

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s