Aria2 : Make your linux box a 24×7 downloader

There are so many things that make me like Linux, the important one among them is that you can run it for days without any memory leaks. Days and weeks and months if you know how to configure properly. Sure, Windows can do it. But its cumbersome and resource hungry even without any leaks.

And what can we do by making the box run for weeks?.  We can run downloads 24×7 or seed-boxes or whatever. Now my interest in this is for running a 24×7 downloader box.

For that I had to square on a perfect resource friendly downloader. That is Aria2 . Since I have done the installation on Ubuntu , what ever I have described below is for an Ubuntu 12.04 .

Setting up Aria2

You can install Aria2 either using apt-get  or you can compile it yourself on your machine. Let’s go through the easy path first.

Getting Aria2 on your box through apt-get

  • Open up terminal.
  • Run
     sudo apt-get install aria2 
  • That’s it you are all set.

Getting Aria2 compiled on your box

  • You can compile the aria2 only if you have the following modules :  gcc, g++, libssl-dev, libc-ares-dev, libxml2-dev, zlib1g-dev, libsqlite3-dev, pkg-config
  • Install these by using  
     sudo apt-get install gcc g++ \
     libssl-dev libc-ares-dev libxml2-dev \
    zlib1g-dev libsqlite3-dev pkg-config
  • Once they are all present in your box. Download Aria2 source code from http://sourceforge.net/projects/aria2/ .
  • Follow these steps to download & compile aria2
  • mkdir ~/Desktop/aria_install
    cd ~/Desktop/aria_install
    wget http://sourceforge.net/projects/aria2/files/latest/download
    tar xvf aria2-*
    cd aria2-*
    ./configure
    make
    sudo make install
  • Now wait for an hour or so ;-).

Now that you’ve installed aria2, it has to be configured.

Configuring aria2

Step 1 : Creating the configuration file for aria2

By default, aria2 will load configuration from ~/.aria2/aria.conf  . You can create following file there or , you can create it in a common place. I will be creating it in /etc/aria2/ .

  • Create the file using these commands in terminal.
    sudo mkdir /etc/aria2
    sudo nano /etc/aria2/aria.conf
    
  • Enter the following content, but change the ‘dir’ to the folder you want aria2 daemon to download to. :
    dir=/media/Downloads
    file-allocation=falloc
    continue
    log-level=warn
    check-certificate=false
    max-connection-per-server=8
    summary-interval=120
    daemon=true
    enable-rpc=true
    enable-dht=false
    rpc-listen-port=6800
    rpc-listen-all=true
    max-concurrent-downloads=3
    http-auth-challenge=true
    save-session=~/Desktop/aria.txt
    input-file=~/Desktop/aria.txt
    log=/var/log/aria2/aria.log
    disable-ipv6=true
    disk-cache=25M
    timeout=600
    retry-wait=30
    max-tries=50
    
  • Tips: ctrl-o  for saving the nano and ctrl-x for exiting the nano
  • After the configuration file is saved. we need to initiate the log file as well
     mkdir /var/log/aria2
    sudo nano /var/log/aria2/aria.log 

Step 2: Making aria2 to automatically start during boot

  • To make aria2 start-up automatically , we have to create an init file inside /etc/init.d and then update the startup configs.  Run the following commands inside bash
     sudo nano /etc/init.d/aria2 
  • Content of aria2 file :
    #! /bin/sh
    # /etc/init.d/aria2
    
    ### BEGIN INIT INFO
    # Provides: aria2cRPC
    # Required-Start: $network $local_fs $remote_fs
    # Required-Stop: $network $local_fs $remote_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: aria2c RPC init script.
    # Description: Starts and stops aria2 RPC services.
    ### END INIT INFO
    
    RETVAL=0
    case "$1" in
     start)
     echo -n "Starting aria2c daemon: "
     umask 0000
     aria2c --daemon=true --enable-rpc --rpc-listen-all -D --conf-path=/etc/aria2/aria2.conf
     umask 0000
     aria2c --daemon=true --enable-rpc --rpc-listen-all -D --conf-path=/etc/aria2/aria2.conf
     RETVAL=$?
     echo
     ;;
     stop)
     echo -n "Shutting down aria2c daemon: "
     /usr/bin/killall aria2c
     RETVAL=$?
     echo
     ;;
     restart)
     stop
     sleep 3
     start
     ;;
     *)
     echo $"Usage: $0 {start|stop|restart}"
     RETVAL=1
    esac
    exit $RETVAL
    
  • Then give it execute permissions
    sudo chmod +x /etc/init.d/aria2 
  • After that we have to update the boot scripts for including aria2
    sudo update-rc.d aria2 defaults
  • That’s it. Now aria2 will start during boot and any GUI will work with aria2c.
  • Oh, by the way.
     sudo reboot

    🙂 .

Few examples of aria2 commands

  •  Downloading a file  
    aria2c   url
  • Downloading a secure file
    aria2c -http-user=user_name -http-user-passwd=password url

Complete.

4 thoughts on “Aria2 : Make your linux box a 24×7 downloader”

Leave a Reply