How to find the fastest Arch Linux and BlackArch mirrors

It is up to the user to choose the mirror of the package repositories on Arch Linux. It is up to the user to decide which mirror or list of mirrors will be used to install and update software packages.

Arch Linux distributions do not provide by default tools to automatically measure the speed and quality of mirrors. The complete list of mirrors is located in the /etc/pacman.d/mirrorlist file, by default all entries are commented out, that is, inactive.

How to update pacman mirror list on Arch Linux

The Arch Linux mirror list is updated as a regular package. With this update, an entry appears that the new list has been installed as mirrorlist.pacnew. This seeming simplicity has a catch – the new mirror list is not used by default. First, it is not referenced in the pacman config file. And, secondly, all entries in it are commented out.

Since the new list of mirrors is always installed as mirrorlist.pacnew, it would be correct not to link to this file (the file will be overwritten with the next update), but to rename this file.

We start by deleting the old backup (if there is one, if not, then skip this step):

sudo rm /etc/pacman.d/mirrorlist.old

Save the old list of mirrors as a backup:

sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.old

Rename the new list:

sudo mv /etc/pacman.d/mirrorlist.pacnew /etc/pacman.d/mirrorlist

Now we need to open and edit the /etc/pacman.d/mirrorlist file. In the GUI:

sudo gedit /etc/pacman.d/mirrorlist

In a headless machine:

sudo vim /etc/pacman.d/mirrorlist

As you can see, all lines are commented out. If we ran pacman, it would give error messages. Remove the hash sign from any line (or any number of lines) beginning with “#Server”. Choose based on your country and your preferences. When upgrading, pacman tries to download package information and packages from the first server in the list. If this fails or the speed is too slow, then it moves on to the next and so on until the list ends. Therefore the more lines you uncomment, the less chances that one day you will not be able to update due to mirrors unavailability.

After that, try updating:

sudo pacman -Syu

How to find the fastest Arch Linux mirrors

If you are using more than one Arch Linux distribution, then you may notice that at the same time, different lists of packages for updates are available on different systems – this is due to the fact that different mirrors are selected, which have different sync interval.

You may also run into a situation where the Arch Linux update takes a very long time due to the fact that new package files are downloaded for a long time. In this case, choosing a faster mirror will help you.

You need to choose the highest quality mirror, which will not necessarily be the fastest

In addition to speed, mirrors are also characterized by:

  • Completion % is the percentage of successful mirror checks, if it is less than 100, then the mirror may be unreliable
  • μ Delay is the delay from the release of package updates to their appearance on the mirror. Anything less than 1 hour should be considered ideal.
  • μ Duration is the duration of the connection during which the lastsync file is downloaded from the mirror. Please note that this value is not calculated from your computer, but from the Arch Linux checking server.
  • σ Duration is the standard deviation of the connect and retrieval time. A high standard deviation can indicate an unstable or overloaded mirror.
  • Mirror Score is a very rough calculation for ranking mirrors. It is currently calculated as (packet update delay + average connection duration + standard deviation) / completion percentage. The lower the value, the better.

A list of mirrors and their characteristics can be found at https://archlinux.org/mirrors/status/

You may have already navigated to the list of Arch Linux mirrors and started choosing a mirror based on the criteria you are interested in, but note that at the top of this page are “Out of Sync Mirrors”, that is, mirrors that are not functioning correctly! The mirrors that are okay are below in the “Successfully Syncing Mirrors” section. I don't know why the authors of this page did this.

This list is regularly updated and the rating is built anew.

So, before moving on to choosing the fastest mirror, select a few of the highest quality mirrors, preferably geographically close to you.

For example, at the time of this writing, the following mirrors were the best:

Server = https://mirror.osbeck.com/archlinux/$repo/os/$arch
Server = http://arch.jensgutermuth.de/$repo/os/$arch
Server = http://mirror.cyberbits.eu/archlinux/$repo/os/$arch
Server = http://mirror.lty.me/archlinux/$repo/os/$arch
Server = http://ftp.myrveln.se/pub/linux/archlinux/$repo/os/$arch
Server = http://arch.mirror.constant.com/$repo/os/$arch
Server = https://mirror.f4st.host/archlinux/$repo/os/$arch
Server = https://archlinux.thaller.ws/$repo/os/$arch
Server = http://ftp.halifax.rwth-aachen.de/archlinux/$repo/os/$arch
Server = https://mirror.erickochen.nl/archlinux/$repo/os/$arch

All of them are located in countries such as Sweden, USA, Germany, France, Netherlands.

Now that you have compiled a list of the best mirrors, place them in the /etc/pacman.d/mirrorlist file.

To check their speed, you can use the rankmirrors utility from the pacman-contrib package, install this package:

sudo pacman -S pacman-contrib

Run the rankmirrors utility specifying the path to the file with the list of mirrors:

rankmirrors -t /etc/pacman.d/mirrorlist

You will see a list of mirrors sorted by speed from your computer to mirror.

To get a list of mirrors sorted by speed, suitable for insertion into /etc/pacman.d/mirrorlist file, run rankmirrors with no options:

rankmirrors /etc/pacman.d/mirrorlist

Note that in this case rankmirrors will display the entire contents of the /etc/pacman.d/mirrorlist file, including the commented lines, at the very end there will be a list of active mirrors sorted by speed.

If you do not want to install third-party tools, then you can roughly estimate the speed of the mirror by the speed of packet synchronization. To do this, you can double the -y option, which will cause the package list to be downloaded again, even if it's up to date:

sudo pacman -Syyu

How to search for mirrors from certain countries, check their quality and speed

Using the reflector script, you can automate the process of finding and analyzing mirrors. Installing the script:

sudo pacman -S reflector

If you run the script without options, it will display a list of all available mirrors:

reflector

To display a list of countries and the number of mirrors in each of them, run the following command:

reflector --list-countries

With the option --country COUNTRY_NAME_OR_CODE (short version -c COUNTRY_NAME_OR_CODE) you can restrict the use of mirrors to selected countries. Countries can be listed by name or country code, or a combination of both. Letter case is ignored. You can specify several countries at once by listing them separated by commas (for example, “--country France,Germany”) or passing this option several times (for example, “-c fr -c de”). Use the --list-countries option to display a table of available countries along with their codes. When sorting by country, this option can also be used to sort in preferred order rather than alphabetically. For example, to select mirrors from Sweden, Norway, Denmark, and Finland in that order, use the “--country se,no,dk,fi --sort country” options to set the preferred sorting order by country without filtering by country. This option also recognizes the wildcard “*”, which will match any country. For example, to ensure that any mirrors from Sweden are at the top of the list and any mirrors from Denmark are at the bottom, with any other countries in between, use “--country 'se,*,dk' --sort country”. However, it is important to note that when “*” is specified along with other filtering criteria, there is no guarantee that certain countries will be included in the results. For example, with the options “--country 'se,*,dk' --sort country --latest 10”, all the latest 10 mirrors can be from the United States. The wildcard only ensures that if specific countries are included in the results, they will be sorted in the requested order.

The --fastest NUMBER option (short -f NUMBER) can be used to specify the maximum number of mirrors to display, sorted by their speed. The following command will display the 10 fastest mirrors from France and Germany:

reflector --country 'France,Germany' -f 10

If you are interested in the mirrors with the highest rating value, then use the --score NUMBER option. Specify the maximum number of mirrors to display. For example, this command will output three top-rated mirrors from Russia:

reflector --country ru --score 3

If you are interested in servers with better synchronization speed, then use the --latest NUMBER (-l NUMBER) option. The following command will display the 3 mirrors from Thailand that were synced the shortest time ago:

reflector --country th -l 3

With the --protocol option (shorthand -p) you can specify the mirror protocol, for example:

  • https
  • http
  • rsync
  • ftp

Multiple protocols can be specified, separated by commas, or by using this option multiple times.

You can display only those mirrors, Completion % (percentage of successful mirror checks, if it is less than 100, then the mirror may be unreliable) of which is not less than the specified value. To do this, use the --completion-percent [0-100] option. The default is 100.0. That is, if you want mirrors with only 100 reliability to be tested and displayed, then this option can be omitted – it is assumed by default.

The --ipv4 and --ipv6 options can restrict mirrors that only support IPv4 and IPv6, respectively.

By default, the list of mirrors is printed to standard output, with the --save option you can specify the path to save the file with the list of mirrors.

The --info option will cause information about them to be displayed instead of a list of mirrors (specify options with filters).

You can automate the updating of the mirror list. There is a reflector.service service for this, before starting it and adding it to startup, examine and edit the /etc/xdg/reflector/reflector.conf file:

--save /etc/pacman.d/mirrorlist
--country France,Germany
--protocol https
--latest 5

The list of mirrors will be updated when the service is started (that is, every time the computer is turned on, if the service is added to startup (enable), or when it is manually started (start)).

Reflector has a systemd timer, reflector.timer, which triggers a scheduled update of the mirror list. You can enable reflector.timer for weekly updates. You can also edit reflector.timer to change the update schedule.

How to find the fastest BlackArch mirrors

Start by updating the BlackArch mirror list, the current mirror list is in /etc/pacman.d/blackarch-mirrorlist file and the updated list is in /etc/pacman.d/blackarch-mirrorlist.pacnew file.

Unfortunately there is no mirror rating for BlackArch. Therefore, you will have to manually edit the /etc/pacman.d/blackarch-mirrorlist file, uncommenting the mirrors that are of the highest quality in your opinion.

Then use rankmirrors to check the speed of the mirrors, and you must definitely specify the -r option with the repository name, otherwise you will receive an “unreachable” error:

rankmirrors -t /etc/pacman.d/blackarch-mirrorlist -r blackarch

To get a copy-and-pasteable list, do not use the -t option:

rankmirrors /etc/pacman.d/blackarch-mirrorlist -r blackarch

Conclusion

So, it is important not only to choose the fastest mirror, it is also important to choose a high-quality mirror, otherwise instead of a delay from downloading, which can be several minutes, you can get a delay of several hours due to the fact that the server does not synchronize new packets for a long time.

As a rule, local mirrors located in the same country as the updated system turn out to be faster, but this rule does not always apply. More precisely, it is more correct to say this: some of the local mirrors may turn out to be faster than those located far away. Don't blindly rely on the fact that the mirror is local – it can be slow and/or have outdated packages due to synchronization issues.

By choosing high-quality mirrors, you will not face a situation where updates on certain systems are delayed for hours or even days.

Recommended for you:

Leave a Reply

Your email address will not be published.