mktorrent

This article will show you how to install a later version of mktorrent. The software is already on the server but only at version 1.0, as this is the latest available in the Debian Jessie repo. A later version of mktorrent allows you to create torrents with the source (-s) option, a requirement of certain trackers.

You'll need to execute some commands via SSH to use this software. There is a separate guide on how to connect to your slot via SSH. Commands are kept as simple as possible and in most cases will simply need to be copied and pasted into the terminal window (then executed by pressing the Enter key).

Installation

Install mktorrent by logging in via SSH, then copying and pasting the following:

git clone https://github.com/Rudde/mktorrent.git
cd mktorrent/ && PREFIX=$HOME make
PREFIX=$HOME make install
rm -rf ~/mktorrent

Installation notes

If your binary directory (~/bin) is not in PATH you'll need to give the full path to any program you wish to run. A better alternative is to simply add ~/bin to PATH with the following commands:

echo "PATH=~/bin:$PATH" > ~/.bashrc
source ~/.bashrc

The rest of the guide assumes you have done this and will simply use mktorrent to run the mktorrent binary, instead of ~/bin/mktorrent.

Using mktorrent

Using the binary with the -h option will display the usage guide:

Usage: mktorrent [OPTIONS] <target directory or filename>

Options:
-a <url>[,<url>]* : specify the full announce URLs
                    at least one is required
                    additional -a adds backup trackers
-c <comment>      : add a comment to the metainfo
-d                : don't write the creation date
-h                : show this help screen
-l <n>            : set the piece length to 2^n bytes,
                    default is 18, that is 2^18 = 256kb
-n <name>         : set the name of the torrent,
                    default is the basename of the target
-o <filename>     : set the path and filename of the created file
                    default is <name>.torrent
-p                : set the private flag
-s                : add source string embedded in infohash
-v                : be verbose
-w <url>[,<url>]* : add web seed URLs
                    additional -w adds more URLs

So, let's say as an example we have a folder, Folder1 that we want to make a torrent out of and eventually upload it to some-tracker.com. The folder is just over 2GB in size, so we want to use 2MB pieces. We'd do all that like so:

mktorrent -a https://some-tracker.com -l 21 Folder1/

We could then, if we wanted to, use transmission-show on the resulting torrent to check everything:

[server ~] transmission-show Folder1.torrent 
Name: Folder1
File: Folder1.torrent

GENERAL

  Name: Folder1
  Hash: 0031b829e1f296072004cd68ab193025195d0193
  Created by: mktorrent 1.1
  Created on: Sat Sep  2 15:14:23 2017
  Piece Count: 954
  Piece Size: 2.00 MiB
  Total Size: 2.00 GB
  Privacy: Public torrent

TRACKERS

  Tier #1
  https://some-tracker.com

FILES

  Folder1/File1 (2.00 GB)

Uninstallation

To uninstall simply copy and paste the following commands:

rm -rf ~/bin/mktorrent