Create your own distribution torrents

1004

Author: Mayank Sharma

The BitTorrent protocol has revolutionized peer-to-peer (P2P) file sharing. It works by enabling users to download fragments of a large file from other users simultaneously, rather than waiting for one file to complete, thus speeding the download process. As a result, many popular Linux distributions have started releasing their ISOs through torrents, many of which you can find at LinuxTracker. But if your favourite distro doesn’t offer a release torrent, why not make your own?

Making a torrent isn’t rocket science, but it requires a little more effort than moving the file into a sharable folder — a method that most P2P software relies on. First, create a directory, then populate it with all the distribution ISOs. It’s also a good idea to include a text file that has the MD5 checksums, to let those who download the software check the integrity of the ISO. Also include any other important readme or instruction files. You also need a tracker, which coordinates the activity of the transfer and keeps track of the packet flows. The tracker is also referred to as the announce URL. For example, LinuxTracker’s announce URL is http://linuxtracker.org/announce.php.

Let’s walk through creating a torrent of the GParted live CD. The directory looks like this:

-GParted_LiveCD_0.2.4-3
	-gparted-livecd-0.2.4-3.iso
	-md5sum
	-readme.txt

Apart from the ISO file, you include a file that has the md5sum of the ISO, as well as a readme file that has some information about the distribution and links to its home page, FAQ, and forum boards.

You can create the actual torrent either through the command line with CreateTorrent, or through a graphical user interface (GUI) with MakeTorrent.

CreateTorrent

CreateTorrent is a small utility you can use to create torrents from the command line. Download the tarball, untar it, and then follow the ./configure, make, and sudo make install procedures to install the utility. The program depends on OpenSSL and some header files that are included in the libssl and libssl-dev packages. If you’re using Ubuntu, just use apt-get to install openssl, libssl, and libssl-dev.

The utility lacks a manual page, but createtorrent -h lists its usage and options. You can specify the announce URL, the port through which BitTorrent data flows, the number of bytes each piece of the file is split into, the path to the file on the server, and any comments to the torrent.

Use this code to create a torrent for http://linuxtracker.org:


:-~/UPLOAD$ createtorrent -a http://linuxtracker.org/announce.php UPLOAD/GParted_LiveCD_0.2.4-3/ GParted_LiveCD_0.2.4-3.torrent
ignoring UPLOAD/GParted_LiveCD_0.2.4-3//.
ignoring UPLOAD/GParted_LiveCD_0.2.4-3//..
adding UPLOAD/GParted_LiveCD_0.2.4-3//gparted-livecd-0.2.4-3.iso
adding UPLOAD/GParted_LiveCD_0.2.4-3//md5sum
adding UPLOAD/GParted_LiveCD_0.2.4-3//readme.txt

This gives you a GParted_LiveCD_0.2.4-3.torrent file under the UPLOAD directory, from where you ran the createtorrent command.

BTMakeTorrentGUI

The BTMakeTorrentGUI utility has replaced the btcompletedir utility as of version 4.0 of the BitTorrent client from Bram Cohen, the creator of the BitTorrent protocol. The latest version for Linux is 4.4.0, and it’s available as both an RPM and a Debian package. Make sure to remove your existing BitTorrent client before installing the new one by using either sudo dpkg -i BitTorrent-Stable.deb or su -; rpm -i BitTorrent-Stable.rpm.

Once installation is complete, running bittorrent from the command line should bring up the torrent GUI. Navigating to File -> Make New Torrent or pressing Ctrl-N should pop open the torrent file creator. Click on Choose and navigate to the file or directory that you want included in the torrent — in this case, UPLOAD/GParted_LiveCD_0.2.4-3. Select a Piece Size, which defaults to 256KB, and specify the tracker — in this case, http://linuxtracker.org/announce.php. Add a comment if you like. Clicking on Make assembles the torrent; once the process completes, you can start seeding directly by clicking on the Start Seeding button. Otherwise, click on OK to return to the torrent creator.

That’s it. Now that you have the torrent file, you can share it with your peers. Upload it to the site whose tracker you specified; LinuxTracker allows only registered users to upload torrents. And don’t forget to seed your own torrent!