📜 ⬆️ ⬇️

Optimize apt-get. We increase the speed of downloading packages

Hello!


Recently I switched to a faster Internet tariff plan. As usual, I started the system, the update started from the repositories. Only here the increase in speed was not noticeable.

Having stumbled upon a recording in a foreign language, I saw an article with the use of the axel utility instead of standard download tools.




.

.

(
25-30k),
wget
.
, . apt-get?
axel: sudo apt-get install axel
- .


The command to download is the same as in wget.
')
axel site.com/file.bin

Next, create an apt-fast file with the following contents:

#!/bin/sh
#apt-fast by Matt Parnell www.mattparnell.com , this thing is FOSS
#please feel free to suggest improvements to admin@mattparnell.com
# Use this just like apt-get for faster package downloading. Make sure to have axel installed

#If the first user entered variable string contains apt-get, and the second string entered is either install or dist-upgrade
if echo "$1" | grep -q "[upgrade]" || echo "$2" | grep -q "[install]" || echo "$2" | grep -q "[dist-upgrade]"; then
echo "Working...";

#Go into the directory apt-get normally puts downloaded packages
cd /var/cache/apt/archives/;

#Have apt-get print the information, including the URI's to the packages
apt-get -y --print-uris $1 $2 $3 $4 > debs.list;

#Strip out the URI's, and download the packages with Axel for speediness
egrep -o -e "(ht|f)tp://[^\']+" debs.list | xargs -l1 axel -a;

#Perform the user's reqested action via apt-get
apt-get -y $1 $2 $3 $4;

echo "Done! Make sure and check to see that the packages all were installed properly. If a package is erred, run sudo apt-get autoclean and try installing it again without the use of this script.";

elif echo "$1" | grep -q "[*]"; then
apt-get $1;
else
echo "Sorry, but you appear to be entering invalid options. You must use apt-get and one of apt-get's options in order to use this script.";
fi


We give him the right to run: chmod + x apt-fast
And copy to / usr / bin for convenience: sudo cp apt-fast / usr / bin

Now to upgrade, we write: sudo apt-fast upgrade
To download and install the package, we write: sudo apt-fast install package_name

The increase in speed is really decent. Especially felt on machines with fast connection to the network when the width of the repository channel is not enough for maximum download speed.

based on webupd8.org

image

Source: https://habr.com/ru/post/77005/


All Articles