Optimize Archlinux's Pacman


Pacman is a packet manager used by Arch Linux and all it's derived distributions. It is the equivalent to apt-get from Ubuntu, and as all packet managers in Linux, allows us to easily install most common, and sometimes uncommon, packets (program) without needing to scour the web for them as in other operating systems.

Pacman is already really fast and many people think it the perfect package manager (me included). However, you can tweak it's performance even further.

For spanish readers, take a look at [frikinux]'s post. He's who told me about reflector, which we will use to get faster downloads from closeby mirrors.

Mirrorlist: download from faster proxys

Pacman uses a mirrorlist located in /etc/pacman.d/mirrorlist. All servers in this mirrorlist contain the same packages (they are mirrors of each others), hence the only difference for the end user is their speed.

From [Frikinux] I heard about a tool called reflector, a script that retrieves the latest mirror list from MirrorStatus and sorts it by speed overwriting the original mirrorlist in our system. To use it first install it, then backup your old mirrorlist and then get the latest top 5 servers.

# pacman -S reflector
# mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
# reflector -l 5 --sort rate --save /etc/pacman.d/mirrorlist 

Database: free up space and accelerate lookups

Pacman uses a database to store information about packages, which later can be used for searches or resolving package dependency. This database is composed of small individual files that need to be regrouped once in a while to avoid unnecessary HDD head movement.

So, following ArchWiki - Improve Pacman Performance, we will first empty pacman's cache with downloaded but uninstalled packages (do not do this if you think that for any reason you will want to revert to older versions of your packages in the future, but for most users this is safe).
# pacman -Sc

And then we will optimize pacman's database.
# pacman-optimize

Powerpill: makes pacman download in parallel

You will have noticed that when downloading several packages pacman does this one at a time. Powerpill is a pacman wrapper that tries to download as many packets as possible simultaneously.

Install powerpill with:
# pacman -S powerpill

And from now on use it instead of pacman. So for example to update our system we would write:
# powerpill -Syu

Note that powerpill is very, so do not be surprised if you see some error messages, they should be taken care automatically.

No comments :

Post a Comment