How to Preallocate Disk Space in aria2?

Configuring aria2 to pre-allocate disk space before starting a large download helps prevent disk fragmentation and ensures that your storage media has sufficient room for the files before investing time and bandwidth. This article explains the benefits of pre-allocation, details the specific command-line options and configuration settings required to enable it, and compares the available allocation methods to help you choose the best one for your file system.

Why Pre-allocate Disk Space?

When downloading large files, especially via BitTorrent or multi-connection HTTP/FTP, data blocks are often written out of order. Without pre-allocation, this leads to heavy file fragmentation, which can degrade storage performance. Pre-allocation reserves the entire file size on the disk immediately when the download begins, ensuring a contiguous block of space and catching “disk full” errors before the download actually wastes your bandwidth.

The Standard Pre-allocation Command

To tell aria2 to allocate disk space before starting a download, you use the --file-allocation option followed by your chosen allocation method.

The basic command structure looks like this:

aria2c --file-allocation=falloc "URL"

Available Allocation Methods

aria2 supports several different methods for reserving disk space. Choosing the right one depends heavily on your operating system and file system:

Making Pre-allocation Permanent

If you do not want to type the command every time, you can add this behavior to your global aria2 configuration file (usually located at ~/.config/aria2/aria2.conf or ~/.aria2/aria2.conf).

Open your configuration file and add the following line:

file-allocation=falloc

Note for Windows Users: The falloc method is not supported on Windows. If you are using Windows with an NTFS file system, prealloc is the safest choice for true allocation, though it will take some time to initialize large files. Alternatively, trunc can be used for instant startup if you are certain you have enough disk space.