Arch linux’s default package manger, Pacman, is one of the best package manager of the linux ecosystem. Its sturdiness and easy way of manage packages provides the core of Arch Linux and other arch-based distros. Altough being fast by default, and having worlwide mirrors available and, there are a couple of improvements that you can do to make pacman much faster
Improvements
Parallel Downloads
We’ll be editing pacman’s main config file,
pacman.conf
using vim editor but you can replace it with the editor of your choicesudo vim /etc/pacman.conf
- Enabling parallel downloads
Under [options] in pacman.conf search for
ParallelDownloads
(it should under Misc Options) and uncomment it if was and set it to 6 This will enable 6 downloads at a time for your next package updates
ParallelDownloads = 6
Bonus: Enable eyacandy
Since we are editing the pacman conf we can enable some cool features to make it look better under the Misc Options enable/uncommentColor
andILoveCandy
options and save. It should look like this
# Misc options #UseSyslog Color ILoveCandy #NoProgressBar CheckSpace #VerbosePkgLists ParallelDownloads = 6 DownloadUser = alpm #DisableSandbox
- Enabling parallel downloads
Under [options] in pacman.conf search for
Mirror List
Correctly choosing an enable nearest pacman mirrors could greatly speed up your package download speed. You should have choose some nearest mirrors at time of the Arch installation, but there is a cool way to update and re rank your mirrorlist at time of update. Pacman provides a script called rankmirrors to rank a list of mirrors according their speed and create a new pacman mirrorlist.
Let’s install the
pacman-contrib
package that provides the rankmirror script and others that we are going to use in the next topic.sudo pacman -Syy pacman-contrib
Then let’s make a backup of your current mirrorlist with
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
We are going to fetch a new mirrorlist from arch site filtering by country codes and pipe the results trough rank mirrors script. The next example will fetch French and English mirrors, replace country codes with your own and nearest countries
curl -s "https://archlinux.org/mirrorlist/?country=FR&country=GB&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 -
There are other tools that can also do this, you can always explore the awesome pacman wiki Mirrors
Optimize AUR builds
If you are using some packages from the AUR repo manually or through any other pacman wrapper as
yay
orparu
there are a couple of cool tricks to make the process of building and installing those packages a bit fasterEnable parallel compilation:
Previously we enabled pacman parallel downloads, but do you know that you could also enable parallel package compilation?
The
make
build system can set the number of precessors used during the build process via MAKEFLAGS env var Some packages in the AUR overrides this in the PCKGBUILD because of race conditions bugs during the build. If you find any bug realated to the build process after enabling this feature, the recommendetion of the wiki Makepag is to fill out a bug to the package maintanier.Let’s edit the
/etc/makepkg.conf
file, and add this to the MAKEFLAGS varMAKEFLAGS="--jobs=$(nproc)"
This will use the
nproc
command to determine the number of available cpus at the time of building the package
Conclusion:
These are just small changes that could really improve the speed of the pacman package manager without affecting the overall functionality of your arch install.
If you know any other improvement, please leave it in the comments.
Comments