Using apt-fast to accelerate installation of Debian packages

man64, 123RF

man64, 123RF

Speed Up!

Apt-fast speeds up software installation under Debian, Ubuntu, and all its derivatives.

The abbreviation Apt stands for Advanced Packaging Tool. This is a console front end for Debian's package manager backend dpkg ("Debian Package"). Together with the package management database, Apt controls the heart of Debian. It is possible to install a package using dpkg, but only with restrictions. Moreover, Apt is definitely more clever when it comes to installation. This utility keeps an eye on all of the dependencies, and it pulls packages from the Debian archive via the package sources. Alternatives to Apt include Aptitude and apt-get, which is gaining the reputation for being old fashioned. This is because Apt uses shorter commands to reproduce the functions of apt-get and apt-cache. In addition, Apt output comes in colors and has a progress bar.

Slow Mirrors

No matter which front end you use, insufficient speeds when you are downloading packages from the server designated in the source list can be bothersome. Users who use Debian "Testing," "Unstable," and other rolling-release distributions are more familiar than they would actually like to be with downloads that consist of several hundred megabytes. The shell wrapper apt-fast [1] intends to alleviate long download times, and it can be used with Apt, apt-get, and also Aptitude.

Apt-fast promises to seriously reduce download times for packages by switching over to a download manager that can handle parallel downloads with numerous connections per package. Of course, this approach only makes sense when your Internet connection is faster than the mirror you are using. You will need to try this out for yourself with the pertinent server. I tested a relatively large LibreOffice download on a 120Mbps connection to find out how much time both Apt and apt-fast need on a freshly installed system.

Installation

Apt-fast has been under development since 2008, and it has been actively distributed under Ubuntu, thanks to the Personal Package Archive (PPA). Accordingly, installation goes quickly (Listing 1). You should work on an initial configuration during installation (Figure 1). You will then need to make manual adjustments in order to achieve optimal speed, but more about this later.

Listing 1

Installing apt-fast

$ sudo add-apt-repository ppa:saiarcot895/myppa
$ sudo apt-get update
$ sudo apt-get -y install apt-fast
Figure 1: When installing apt-fast from the Ubuntu PPA, one of your configuration tasks will be to configure your package manager.

You can also pull the source code from GitHub and do a manual installation as shown in Listing 2. The most recent modification dates from about three months ago. In other words, the developers are still actively working on the script. Even so, it is a safe bet that no changes are planned for basic functions.

Listing 2

Manual installation

$ git clone git://github.com/ilikenwf/apt-fast.git
$ sudo cp apt-fast/apt-fast /usr/sbin/
$ sudo chmod +x /usr/sbin/apt-fast
$ sudo cp apt-fast/apt-fast.conf /etc
$ sudo chown root:root /etc/apt-fast.conf
$ sudo chown root:root /usr/sbin/apt-fast
$ sudo cp apt-fast/apt-fast.comp /etc/bash_completion.d/apt-fast
$ sudo chown root:root /etc/bash_completion.d/apt-fast
$ . /etc/bash_completion
$ sudo apt install aria2

You can also install an up-to-date version of the program with QuickInstall. Use the command from the first line of Listing 3 in order to call the QuickInstall script. This command transfers the script, makes it executable, and also installs the apt-fast download manager aria2 onto the system (Figure 2). Since you want to make apt-fast available for the fastest mirror in your environment, you should also install the netselect-apt package (lines 3 to 6).

Listing 3

QuickInstall installation

01 $ sudo /bin/bash -c "$(curl -sL https://git.io/vokNn)"
02 $ wget -O- http://neuro.debian.net/lists/yakkety.us-ca.full | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list
03 $ sudo apt-key adv --recv-keys --keyserver hkp://pgp.mit.edu:80 0xA5D32F012649A5A9
04 $ sudo apt-get update
05 $ sudo apt-get install netselect-apt
Figure 2: It is easy to install apt-fast from GitHub using the QuickInstall script.

Locating Fast Servers

Use the command:

sudo netselect-apt -t 5

to find the five fastest servers in your environment (Figure 3), and add them to the configuration file. If you come up with other servers during testing, then you should use these. Copy the modified configuration file named apt-fast.conf to /etc/ and assign appropriate access rights to the file using:

sudo chown root:root /etc/apt-fast
Figure 3: Netselect-apt selects the fastest servers in your area.

If you want to always use apt-fast, it is a good idea to set up an alias in /etc/bash.bashrc . You can do this with the following command:

$ sudo echo "alias apt='apt-fast'" >> /etc/bash.bashrc

Now you can use apt-fast, for example, by entering apt install <Package> or apt dist-upgrade . Depending on your preferences, you could also do something like convert the configuration file from apt-get to the newer Apt, thus adding a feature such as a progress indicator.

Editing apt-fast.conf

This is done by replacing apt-get with the editor of your choice in the apt-fast.conf file, which you copied previously. You should go to the #_APTMGR line and insert /usr/bin/apt or, if you prefer, also /usr/bin/aptitude . In order to activate this line, you should remove the hash sign # at the beginning of the line before saving. The commentary in /etc/apt-fast.conf (shown in Figure 4) describes how to exchange the mirror server.

Figure 4: The control file /etc/apt-fast.conf contains numerous useful examples for configuring apt-fast.

Now you can use apt-fast with the fastest Debian and Ubuntu servers in your area and download packages in parallel with multiple connections. The syntax is identical to that of apt-get, except you use apt-fast with install , remove , upgrade , and dist-upgrade , and so on. Or you can use the alias that you defined before.

Performance

It is difficult to predict whether it pays to use apt-fast since I don't know the circumstances you are dealing with. I performed my tests with an optimized apt-fast.conf , a 120 Mbps connection, and installations of the LibreOffice package on a freshly installed system. During the course of downloading the package several times, download times were reduced by one fifth or even half. Downloads that take between 7 and 10 seconds without apt-fast usually require about 5 seconds when the utility is used on an identical system.

Conclusion

The speed of your available mirror and your download volumes will determine whether it makes senses to go through the effort of installing and configuring apt-fast.

You gain an additional advantage due to the installation of the download manager aria2. This is because it lets you increase the speed of all downloads, even when apt-fast is not involved. This tool only comes with command-line control [2]. However, webui-aria2 [3] also has a graphical interface for the browser.

A closer look at the apt-fast components did not reveal any negative side effects that occurred when it was installed as the Ubuntu package manager. The one piece of criticism I would like to offer is that the developer should move the quick installation to /usr/local/bin/ since the dpkg package manager is the only thing that actually belongs in /usr/bin/ . Otherwise, it would be fair to say that if apt-fast is helpful to you, there is nothing that says you shouldn't use it.