Download from the fastest mirrors on Arch Linux with Reflector

Fast linux

When downloading packages from the repositories of our distribution GNU / Linux, it is important to configure the fastest mirrors so that the download takes place in the shortest possible time. Usually it is recommended to select the mirrors closest to our location for this purpose, although in practice this is not always the most appropriate, since the response speed of the same server where the mirror is hosted has more influence.

In the case of Arch Linux, on the page of mirror status The developers have posted a table with all known mirrors and it is automatically updated showing their status and response speed. If we wanted, we could take those that we like from there and enter them manually in our mirrorlist, although to help us make this task easier there is Reflector.

Reflector is a script that is in charge of consulting the data provided by Mirror Status and allows us to work with them in different ways using commands in the console. Now we are going to see how to use it to automatically configure the fastest mirrors before each update.

Instructions

Let's start by installing the package Reflector from the repositories:

# pacman -S reflector

To see all the available options we can take a look at its help manual:

$ reflector --help

A basic use would be this:

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

Explanation:

  • –Sort: Tells Reflector what parameter you should use to sort the mirrors. The available options are rates (download speed), score (score in Mirror Status), country (country of location), age (age of last sync) and delay (delay time). In this case we are telling you to order them according to your best download speed.
  • -l: Limits the number of results to the number of mirrors that we indicate, taking into account the date of the last synchronization. Here we tell you to provide us with the 5 most recent mirrors.
  • –Save: Sets the file where it will print those 5 fastest and most recent mirrors it found. The file where we need them is obviously our mirrorlist. It is very important to make a backup of the original mirrorlist first.. During the installation, Arch Linux creates one automatically in /etc/pacman.d/mirrorlist.original, but it doesn't hurt to make sure it's there or create one if it doesn't exist.

In this way, to download from the best mirrors it would be enough to make a backup of our original mirrorlist and then call Reflector with the command already mentioned. However, it is obviously a very long command that is probably difficult to remember or lazy to write. A good alternative would then be create an alias to invoke it with a simpler command.

In a common installation with Bash We just have to open the ~ / .bashrc file with a text editor and put a line at the end like this:

alias nombre_del_alias='comandos a ejecutar'

Apply the changes:

$ . .bashrc

And with that we can now execute the orders we want with a custom command. For example, for Reflector i use this:

alias update='sudo reflector --sort rate -l 5 --save /etc/pacman.d/mirrorlist && yaourt -Syyu --aur --devel'

Thanks to that alias, when I want to update the system all I have to do is write Update in the terminal, which makes Reflector print the 5 fastest and most recently synced mirrors to the mirrorlist, and then run Yogurt to carry out a complete update of both the packages of the official repositories and those of AUR and devel.

Now it is up to each person to customize the alias according to their needs. Maybe they want to use the same one as me or prefer to create one just for Reflector, or replace Yogurt by Packer or simply Pacman. The possibilities are endless.

In closing, it should be noted that using Reflector Before each update, it will initially take a little longer than normal to query Mirror Status, although it will be compensated by the higher speed it will provide when downloading the packages.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   illukki said

    I have had problems with mirrors for several months. Despite using reflector, every one or two weeks, I get error with them when updating; as if they were fallen and that which Europeans generally use (before the Brazilians used). So I have to continually change them.
    When I have time I will dedicate myself to finding out what the problem is.
    Good post, greetings.

    1.    Manual of the Source said

      The same thing happened to me, that was precisely why I made the alias to call Reflector before each update, since otherwise, if a mirror worked well for me in an update, for the next it was possible that it was no longer responding.

    2.    You Buntu said

      I have experienced problems with downloads not only in Ubuntu, but with the installation of Arch, Debian, Suse ... where, suddenly, the download speed, mainly of larger files such as kernel, libreoffice or linux firmware, drops below 640 Kb / sa 22 Kb / s, and it takes forever, but… there is a bug, God bless you !, that allows me to speed up the download:

      When that disagreement happens, what I usually do is launch the Firefox browser, and the download goes up to 1200 Kb / s for about 10 seconds and starts to go down again, so I keep opening and closing it, or opening and closing pages, how much The longer it takes to load, the longer the impulse will be until the file download is finished.

      The fact that it goes up to 1200 kb / s I think is due to the adsl contract up to 10 Mb although usually only 5 arrive, if at all.

      I hope someone helps, ah! And it can also be used during the installation, last night I was installing Chromixium in VirtualBox to test it and then install it on a laptop of someone who needs to migrate from Güindous, although in the end I installed Antix, and launching Chrome greatly sped up the download time.

      Greetings.

  2.   mat1986 said

    I mention as a detail that Bridge Linux -based on Arch- incorporates Reflector by default, so the process was only to apply "sudo pacman -Syyu" and Reflector worked automatically.

    1.    Manual of the Source said

      Do you happen to know what parameters the Reflector of that distro uses?

      1.    mat1986 said

        The following paste is part of the Bridge Linux post-install script: http://paste.desdelinux.net/5059

        More info here:
        http://millertechnologies.net/forum/index.php?topic=829.msg4300#msg4300

        1.    Manual of the Source said

          I see, they have it set to take mirrors synced in the last 10 hours and use the parameter -f instead of –Sort rate to list the 5 fastest mirrors. The truth is that I have never understood why Reflector has those duplicate options; as well as it also has –Sort country y –Country. It would be a question of investigating what advantages one has over the other. Thanks for the input. 🙂

  3.   babel said

    Wonderful entrance. Thanks for the tip, I had not even realized what aliases could be used in this regard. I'm going to apply it on both of my computers with Arch.

  4.   Abaddon said

    One drawback is that the fastest mirrors are not always in sync with the latest packages.

    On several occasions I have checked that the Arch main page shows the update of X package but not even with -Syyu such an update appears. That is why I prefer "–sort score" over "–sort rate".

  5.   bitl0rd said

    We can also use a script from aur we can download it "armrr-git"

  6.   jose said

    Hello, after doing this, yaourt throws me the following error:
    AUR error: Invalid query arguments
    error: database not found: aur

    I have modified the bashrc leaving it as source, I have uninstalled reflector, I have put the source mirrorlist and I have reinstalled yaourt, but it cannot find the aur database, in pacman.conf if the archlinuxfr repo is there, but I don't know where to throw
    All the best