2009 10 Playing Fetch Building a Dedicated Download System with Rtorrent


Building a dedicated download system with rTorrent
Playing Fetch
Your old computer might still be useful as a dedicated download box.
By Aditya Shevade
Victoria Moody, 123RF
Before you throw away the old PC in your basement, you might be wondering whether you can find another
use for it. An out-of-date computer that is too light for today's GUI universe still has value - if you can find
the right job for it. I put my old PC to work as a BitTorrent-ready download slave that spends its cycles on
fetching large files so my production systems can worry about other tasks.
All you need is a light Linux distribution that fits on your old computer, a torrent client, and a few other tools
to control and manage the system.
Which Tools?
The computer I am using as my download slave (remote computer) is a Pentium 2 with a clock speed of
500MHz and 96MB of SDRAM. For the example in this article, I will use Debian Linux, but you can use any
Linux distribution supported by the hardware.
To begin, download the minimal Debian net install image from the Debian website [1] and install the image
on the old system by any suitable method (network boot, CD install, GRUB image mount - look online for
more on Debian installation options [2]).
The next step is to set up a torrent client for the system. Linux offers a number of torrent alternatives. In this
case, I opted for functionality over simplicity and chose rTorrent [3]. rTorrent (Figure 1) is a command-line
torrent client for Linux that uses nCurses for the menus and interface and libTorrent as a back end.
Playing Fetch 1
Figure 1: Although the interface is primitive by modern standards, rTorrent's main view contains some useful
information.
The main advantage of rTorrent, in this case, is its small memory footprint. Unlike popular GUI clients such
as Azureus or Deluge, rTorrent uses very little memory when downloading torrents. Additionally, rTorrent is
very easy to control over the network.
Setting Up the SSH Daemon
The next step is to install SSH so you can control the remote slave over the network. To set up SSH on Debian
and make it run every time the computer boots, enter the following commands (as root):
apt-get install ssh -y
update-rc.d ssh defaults
Also, you can start the server manually with the following line:
/etc/init.d/ssh start
Just remember that you will have to install and configure SSH on both systems. Now edit the file
/etc/ssh/ssh_config to enable the following options (just uncomment them from the default file or add them if
necessary):
Protocol 2
PermitRootLogin no
Then make sure you add the following option to the /etc/hosts.allow file:
SSHD: ALL
This option will allow all the connections to and from the host and remote systems. At this point you can
access this computer over the network with SSH.
To connect to the remote computer, issue this command on the master:
ssh -l userName IpofTheRemoteSystem
If you don't know the IP address of the remote PC, you can get it by issuing the ifconfig command on the
remote system. If it isn't possible to obtain the IP address that way, you might need to improvise a way to
address the remote computer (see the box titled "But I Have a Dynamic IP Address").
But I Have a Dynamic IP address
Playing Fetch 2
It isn't always possible to obtain the IP address of a remote computer. If you want to access a remote system
that doesn't have a static IP address, you will need to find a workaround. Several strategies have evolved for
supporting connections to computers with dynamic addresses. The no-ip.org website, for instance, lets you
create a hostname that points to your dynamic IP address.
An account on the no-ip.org website is free. Once you set up your account, click on Hosts/Redirects in the
user control panel. The free account only supports up to five free redirects. Now add a redirect. The default
account type should be fine in this case. By default, all firewalls and ISPs block the common ports for
security reasons. Check your router configuration and open the port you are using to run SSH (22 in this
case). Also, open the port from the firewall if you are using a firewall on your system. With the free
CanYouSeeMe.org online service [6], you can check to see whether a connection attempt is possible through
the SSH port. Just enter the port you want to check.
The hostname you just set up needs to track the changes in the IP of the remote machine. See the no-ip
documentation [7] for information on setting up the no-ip script, which updates the dynamic IP and binds it
with your domain.
Figure 2: Monitoring the status of a torrent.
Configuring rTorrent
Now that your SSH connection is working, you can move on to setting up rTorrent on the remote system. If
you are new to torrents and downloading, Wikipedia has some useful background information on the
BitTorrent protocol [4]. When accessing your rTorrent client, I recommend you use the Screen window
manager. Screen is a full-screen window manager that lets you multiplex a physical terminal between several
processes, which means you can put the program in the background easily; plus, you'll have some protection
against accidentally closing the application.
Next, create a file called .rtorrent.rc in your home directory (touch ~/.rtorrent.rc). To start, you can download
a sample rtorrent rc file [5] and save it to ~/.rtorrent.rc. Before editing the file, create the ~/.rtorrent directory
and other supporting directories:
mkdir -P ~/.rtorrent/sessions/
The sessions directory will save the status and the torrent files of the torrents you are currently downloading,
which saves you from having to check the hash every time you start rTorrent. The sample RC file is
self-explanatory - just uncomment the settings you want to override and change the default values. For
example, you can set the default upload or download speed.
Once you've configured all the necessary options, save that file. Although you can start using your download
box anytime, I suggest you read on for some additional tips on configuring your system.
Even though rTorrent is a great piece of software, it has some downsides. Problems include an inability to
queue the torrents, no option to prioritize the first or last piece of a torrent, and no option to add a new tracker.
A few changes to your configuration will improve your rTorrent experience.
Playing Fetch 3
First create the watch directory. rTorrent will monitor this directory to check for any new torrents to add:
mkdir ~/.rtorrent/watch
Then edit your rtorrent.rc file and add following lines of code to the file:
schedule = watch_directory,10,10,load_start=~/.rtorrent/watch/*.torrent
schedule = tied_directory,10,10,start_tied=
schedule = untied_directory,10,10,close_untied=
These lines tell rTorrent to start the torrents that are added to the watch directory automatically. The directory
will be checked every 10 minutes. Any torrents already added will resume, and the system will remove any
torrents that have been deleted from the watch directory.
Additionally, you can add a few more options to create symbolic links, which will monitor the status of the
torrents and will move the completed downloads to a directory you specify once the download is complete. To
create the symbolic links in the watch directory, add the following lines to the rtorrent.rc file:
on_start = link1,
"create_link=tied,,.started"
on_stop = link1,"delete_link=tied,,.started"
on_finished = link1,"create_link=tied,,.finished"
on_erase = link1,"delete_link=tied,,.finished"
The following line moves the completed downloads to the location you desire:
on_finished = move_complete,"d.set_directory=~/Download/ ;execute=mv,-u,$d.get_base_path=,~/Dow
Just replace ~/Downloads with the directory you put your downloaded files.
If you don't have unlimited Internet bandwidth, you might want to stop downloading at certain times (e.g., the
non-free hours). By adding the following lines to your rtorrent.rc file, you can schedule your download time:
schedule = throttle_1,01:00:00,24:00:00,download_rate=0
schedule = throttle_2,05:00:00,24:00:00,download_rate=25
# Format of this is,
#schedule = throttle_x,startTime,finishTime,download_rate=rateInkBps
Now that the necessary infrastructure is in place, you can put your download system to work.
Adding a Torrent
To add a torrent, ssh into the remote machine and log in to your account. At the command line, open rTorrent
with the following command:
screen rtorrent
To control rTorrent through SSH, you can use the normal key bindings (see Table 1). The best part is that if
you paste the link of a torrent file (e.g., if your torrent is at www.torrentsite.com/tor.torrent) and paste it to the
load prompt of rTorrent, rTorrent will download the file.
Playing Fetch 4
Another way to add a torrent is to ssh into the remote machine and wget the torrent file in the watch directory:
wget URLToTorrentFile
The preceding command tells rTorrent what to do with the file depending on the current state of the torrent
(see the preceding section). Table 1 shows a list of useful rTorrent key bindings.
If you want more detailed information about key bindings, go to the rTorrent man page.
Conclusion
That old computer of yours will come in handy as a dedicated download system. For quite some time now, I
have used this configuration successfully. Of course, if your system has the necessary resources, you might
want to opt for a GUI-based interface for managing the torrents, which is possible with the alternative
wTorrent tool. Happy Downloading!
INFO
[1] Debian net install image: http://www.debian.org/CD/netinst/
[2] Debian Installation Manual: http://www.debian.org/releases/stable/installmanual
[3] rTorrent: http://libtorrent.rakshasa.no/
[4] Wikipedia on BitTorrent: http://en.wikipedia.org/wiki/BitTorrent_(protocol)
[5] rtorrent.rc sample: http://libtorrent.rakshasa.no/export/1094/trunk/rtorrent/doc/rtorrent.rc
[6] CanYouSeeMe.org: http://www.canyouseeme.org/
[7] no-ip docs: http://www.no-ip.com/support/guides/update_clients/setting_up_linux_update_client.html
THE AUTHOR
To learn more about Aditya Shevade, go to http://www.adityashevade.com or http://blog.adityashevade.com/
Playing Fetch 5


Wyszukiwarka

Podobne podstrony:
2009 10 Reboot Restore Securing Your Linux Lab with Resettable User Accounts
2009 10 OpenCV systemy wizyjn Nieznany
2009 10 IMB ochrona przed korozja
EGZAMIN 2009 10
2009 10 27 Wstęp do SI [w 04]id&835
Serie (5) Zadan Trudnych 2009 10 Osekowski p5
2009 10 STATYSTYKA PARAMETRY Z PROBY
2006 10 Idle Cycles Building Distributed Applications with Boinc
Historia 2009 10 etap rejonowy odp
2009 10 Programowanie przy uzyc Nieznany
K2 2009 10 zad 1
2009 10 Akwizycja i analiza pamięci
2009 10 Secret Stick a Usb Dongle for One Time Passwords
E1 2009 10 zad 3
Zagadnienia Egz 2009 10
2009 10 Mousetraps
Ulotka logo 2009 10

więcej podobnych podstron