Friday, November 30, 2007

Setting up a dedicated torrent server

What is bittorrent?
If you don't already know, you should stop reading now.

Why would I want to set up a dedicated torrent server?
I live in a country where my only option for English TV/Movies is crap cable with constant reruns of CSI and Van Damme bashers. In my first town here, there weren't even English movie theaters within two hours' travel. Maybe you're in a similar situation. Maybe you are just lazy and never want to leave the house. Whatever the reason, if you already download a significant amount, you may want a torrent server.

Why? Aren't mTorrent and Azureus enough for anyone? Not really.

Desktop torrent clients are ... well ... tied to my desktop. I can't logout. I can't shut down. My user experience suddenly starts crawling because my torrents are blazing down at record speed. Whatever the reason for the slowdown is, I found my desktop experience rather pallid with a bittorrent client. I think most people are in a similar situation, judging by how many discussions there are on the internet about trying to get a lighter client.

So what do we want?
I wanted a headless server that just ran all the time. In fact, it made sense for this server to do double-duty as a file server, as well, since I needed to get the files off of the server somehow.

You will need the following specs:
  • CPU: Whatever you find here is probably good enough. If you add TV-out and a video front-end to your server, like Elisa or MythTV, you'll want something strong enough to handle the load.
  • RAM: More is better, but you don't need 4GB or anything. 1GB will certainly handle everything.
  • Graphics card: You've got to be kidding. It's headless. Get something on-board. If you want TV-out, get a low-end card with well supported TV-out, like the Intel chipsets, SiS, or NVidia. I've had a lot of bad experiences with ATIs video out, but that may not be the case now that ATI has released specifications for their cards.
  • Disks: Big and fast. I can fill a 300GB disk in about three weeks. If I'm downloading a well-seeded Linux distro, I can hit 1MB/sec download, so the disk need to be fast enough to catch up. A big cache is good because the disk will spend a lot of time seeking if you have 6-8 torrents running at the same time. CD/DVD drive is probably only necessary to make installation easy.
  • Network: 100Mb/sec should be enough for just about anyone, but you can go with 1Gb/s if it makes you feels safer. You'll probably bottleneck at the disk drive, anyway.
  • Keyboard: Yes
  • Mouse: No
  • Case: Buy a larger one with space to add drives. Trust me. You'll need them.
  • Remote: If you do TV-out, it's probably a good idea, but I won't tell you how to do that here.

Buy The parts for about 300Kwon (350USD) and assemble the computer. Temporarily attach a monitor and CD drive so that you can do the install. Download an Ubuntu Server CD. Install the operating system with a LAMP stack. That will make everything easy.

Once the OS is installed, we should add SSH so that we can administer the server remotely while sitting comfortably at a desk. aptitude install openssh-server.

Remove the monitor, stick the server in a corner or closet, and go sit down at your desk. Log in to the server remotely.

Next, we need to add the torrent server. I have used Torrentflux as a server for quite some time. It is mature and works well. I used to have to download and manually configure, but now you can just use aptitude or apt-get to install it. Everything is simple. aptitude install torrentflux.

The installation screens will handle the configuration for you and help you set up the database and admin account.

When you are finished, open your webbrowser and navigate to http://{server IP}/torrentflux to log in. You will probably only need the administration account, but you might consider multiple accounts if you have roommates or a vicious family.

Finalizing the install
You'll need to look at the ports your server has assigned for bittorrents and forward those ports from your router to the server. If you've been bittorenting for a while, you probably already have ports forwarded to your desktop, so I won't tell you how to do that. While you're at the router, you may want to set up a QOS system limiting your up and down rate from the server. Especially look at upload rate, since saturating the upload will kill your Internet browsing.
Starting torrents
There are several ways to start torrents in Torrentflux. The most direct way is to upload a torrent file from your desktop machine. The torrent will be added to the list of available torrents but won't be started by default. You'll need to click on the little green arrow to do that.

The next way to get a torrent is to download it directly from the torrent site to the server. To do this, you copy the torrent download link from a website and click the button. This only works for public trackers. Sites which require a password will need a cookie file installed on the Torrentflux server. See the TF site for instructions on how to do this.

The Simplest way to add a torrent is to use the supplied search sites. Torrentflux will scrape the web page of a major site and return information about your search. Clicking on the link to the torrent automatically adds it to the list of available torrents. I use this method 95% of the time.

Torrentflux works really well out of the box, but if you want a little extra chocolaty goodness on top, enable the queue engine. It was really unstable for a long time, but they've gotten that fixed now. You can limit the number of active torrents to a good number like six or eight. After that, torrents which are started will join the queue and be next up in line to start once one of the current torrents finishes. To make this work, you need to set a seed limit on your torrents so that they stop automatically. Queues are great when you go on vacation or are away for a few days.
Setting up Samba
I'm not actually going to document this here because there are already a number of really good resources on the Ubuntu site and Ubuntu forums. I will say that, for ease of use, you should set up your share to force read/write as the www-data user by default. This will ensure that there are no permission problems.

If you don't feel like setting up Samba, NFS, or FTP, Torrentflux does offer a simple but effective web interface for managing your torrents downloads.

Happy torrenting!!

  • The Torrentflux site:
  • More about Torrentflux:
  • The Ubuntu Server Install Edition:
  • Installing the Ubuntu Server Edition:
  • Installing Samba on Ubuntu:
  • Installing MythTV on Ubuntu:
  • Screenshots courtesy of the Torrentflux website.


  1. I've been using a media server as a torrent machine for a while now, and originally started off using BTDownloadCurses as it meant I could (using screen) control it remotely, but more recently I've discovered RTorrent, which also runs in a terminal, but is much more fully featured, and most importantly can run multiple torrents simultaneously, and allows global throttling. Having seen this post, and noticed that you appear to be using a GUI based torrent client on your server, I thought you might be interested in it. It's a little more complicated to learn, because you use keyboard shortcuts instead of clicking, but it does seem to do everything I want it to, so I'd heartily recommend it!

    Oh yeah, and it's in apt, so nice and easy to get!

  2. Laurence,

    Thanks for the comment. I used a few different torrent clients ofr a couple of years before TorrentFlux, including many command-line versions with screen, but teaching my SO to use these systems was difficult.

    Torrentflux is a web app, so I still admin remotely. In the newest Epiphany, though, my local web server is discovered automatically through avahi (bonjour) and put into Bookmarks -> Nearby Sites.

    Overall, Torrentflux is a lot easier to admin remotely than using e.g. bittornado or btdownloadmanycurses through the command line and screen. My only complaint is a lack of bandwidth throttling, but I can do that at the router using QOS.

    Now that Torrentflux is available through apt, life is sweet.

  3. Thank you for the lucid walk-through. I was having trouble remote logging into a headless server and slapping some torrents on. =)

  4. This is pretty old, but it still works. I'm putting together a HowTo for a dedicated Torrent / Media Center right now. It's a little more work, but a lot sexier.

  5. What's the URL to view TorrentFlux?


    e.g. ?

  6. It depends on where you have configured it to be, but I believe $IP/torrentflux is the default. Check /etc/apache2/sites-enabled/ for the configuration file.


Other I' Been to Ubuntu Stories

Related Posts with Thumbnails