|
apt-fast and Axel: Roughly 26x Faster apt-get Installations and Upgrades |
|
Monday, 02 June 2008 |
Yes, this will work for any distro that uses apt-get, and the concept should work for all of the others...it may even be as simple as removing wget and replacing it with a symlink to axel.
I have created a little shellscript that increases the speed of apt-get by many times. You need to have the axel download accelerator installed, which is a simple, short process, but everything else is extremely straight forward. I started out downloading the upgrades for the newest version of Ubuntu, at 32kb/s. Not terrible, but not that great. When I was done with the script here, I was getting up to ~850kb/s. That's great, huh?
To do this, you first need to download and install the axel download accelerator. It is really a good drop-in replacement for wget, as it is bash based. Once installed (just follow the readme), we are ready to download our updates at amazingly fast speeds.
Paste the shellscript below into text editor somewhere, and save it as "apt-fast " and chmod +x apt-fast :
#!/bin/sh #apt-fast by Matt Parnell http://www.mattparnell.com , this thing is FOSS #please feel free to suggest improvments 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
|
Once done, just use it like apt-get. To install a single package, make sure your database is up to date, and run sudo ./apt-fast install packagenamehere. Watch it download with incredible speed, and install. To upgrade or dist-upgrade, do the same thing. Just use sudo ./apt-fast dist-upgrade or sudo ./apt-fast upgrade. That's all there is to it!
Should your download stall for any number of reasons, you'll need to go into the apt-get cache directory and remove the offending package, and then re-download it.
This is a FOSS script, of course, so please improve upon it and modify it as you will. If you figure something out better than the original, please post it in the comment section, below.
|