mktorrent
Create BitTorrent metainfo files
TLDR
Create a torrent with 2^21 KB as the piece size
Create a private torrent with a 2^21 KB piece size
Create a torrent with a comment
Create a torrent with multiple trackers
Create a torrent with web seed URLs
SYNOPSIS
mktorrent [OPTIONS] <target_file_or_directory ...>
mktorrent [OPTIONS] -o <output_file.torrent> <target_file_or_directory ...>
PARAMETERS
-a <url>
Specify a tracker URL. This option can be used multiple times to include multiple trackers in the torrent file.
-c <comment>
Add a descriptive comment string to the torrent's metadata.
-h
Display a brief usage message and exit.
-l <piece_length>
Set the piece length in bytes. The value is a power of 2, where <piece_length> is the exponent (e.g., -l 18 sets a piece size of 218 bytes, which is 256 KB).
-n <name>
Force the name of the torrent. By default, the torrent name is derived from the target file or directory name.
-o <file>
Specify the output filename for the .torrent file. If this option is omitted, the torrent data is written to standard output.
-p
Set the 'private' flag in the torrent metadata. This flag indicates that the torrent should only use the tracker for peer discovery, disabling Distributed Hash Table (DHT) and Peer Exchange (PEX).
-v
Display the mktorrent version information and exit.
-w <url>
Add a web seed (HTTP/FTP seeding) URL to the torrent metadata. This option can be used multiple times.
DESCRIPTION
mktorrent is a compact command-line utility designed for generating BitTorrent metadata files, commonly known as .torrent files. These files are essential for sharing content over the BitTorrent network, as they encapsulate critical information about the data being shared. This includes the names, sizes, and cryptographic SHA1 hashes of the content's pieces, along with the URL of the BitTorrent tracker responsible for coordinating the peer-to-peer distribution.
The tool offers capabilities such as specifying multiple tracker URLs, adding descriptive comments, setting custom piece sizes, and marking torrents as 'private' to restrict peer discovery to the tracker. Its minimalistic nature and command-line interface make it particularly well-suited for automation, scripting, and integration into custom workflows for efficient and controlled content distribution.
CAVEATS
mktorrent primarily focuses on creating the .torrent metadata file and does not manage torrent downloads or uploads. It does not natively support creating magnet links directly, nor does it typically include built-in features for peer discovery mechanisms like DHT or PEX unless explicitly configured via the 'private' flag. For advanced torrent functionalities or client-side operations, integration with a dedicated BitTorrent client is required.
PIECE SIZE SIGNIFICANCE
The piece size (set with -l) determines how the torrented content is divided into chunks. A well-chosen piece size balances efficiency (fewer hashes, smaller .torrent file) with resilience (smaller chunks are faster to verify and re-download if corrupted).
STANDARD OUTPUT USAGE
When the -o option is omitted, mktorrent outputs the binary .torrent file data to standard output. This allows for powerful piping operations, such as immediately compressing, encrypting, or transmitting the generated torrent file to another command or service.
PRIVATE TORRENTS AND TRACKERS
The -p flag (private torrent) is crucial for controlling how peers discover each other. For private trackers, this flag ensures that peers only communicate through the tracker, preventing external discovery via DHT or PEX, which helps enforce tracker rules and ratios.
HISTORY
mktorrent emerged as a straightforward, command-line utility for generating BitTorrent metafiles. Its development has been driven by the need for a lightweight tool that can be easily integrated into scripts and automated workflows, without the overhead of a full-fledged BitTorrent client. It has maintained a stable feature set, focusing on core torrent creation capabilities, and remains a popular choice for users and administrators who prefer a minimalist, efficient approach to publishing torrents on Linux systems.
SEE ALSO
transmission-create(1), aria2c(1), rtorrent(1)