Use pacman-mirrors to Set the Fastest Download Server

From Manjaro Linux
Jump to: navigation, search

Overview

Pacman-mirrors complete reference

On the page Pacman-mirrors you will find a complete reference and detailed examples of its possible use.

Mirror service

On the webpage http://repo.manjaro.org you can see the status of every mirror serving Manjaro packages.

The official Manjaro repositories (also known as mirrors) are hosted on Software Servers. Physically located throughout the world, these servers are responsible for receiving requests for software packages via the terminal and/or pacman-gui, and consequently delivering them to your system. There are therefore three primary factors that will determine how fast your downloads are:

  • Your internet connection
  • The speed of the server itself, and
  • The proximity of the server to you (i.e. how close or how far away it is)

Barring upgrading your internet package or switching providers, it is therefore potentially possible to improve the speed of downloads from the Manjaro repositories by using the pacman-mirrors -f command. This will automatically probe mirror servers available and up-to-date for your system branch and consequently update the /etc/pacman.d/mirrorlist file, placing them in order from fastest to slowest.

The Mirrorlist file is itself used by Manjaro's package manager pacman to tell it the internet addresses of the Manjaro servers in order to download updates and software applications from them. Alternatively, it is possible to manually determine which server(s) to use, by using the Change to a Different Download Server guide.

The recommended way

Tip: Remember to run pacman -Syyu after using pacman-mirrors to ensure the pacman databases is current for your system.
It is so important that all examples include an addition && sudo pacman -Syyu.

To run the pacman-mirrors app, you will need root privileges to do so, otherwise permission will be denied.

Using pacman-mirrors --fasttrack [number]

The preferred way of getting servers for your mirror list is to use the -fasttrack [number] or -f [number] argument. This ensures you connect to a server with the latest software. The [number] is the number of servers you want written to your mirror list. The default is using all up-to-date mirrors for your branch. To optionally limit the number of mirrors probed supply a positive integer after --fasttrack.

Example - all mirrors

sudo pacman-mirrors --fasttrack && sudo pacman -Syyu

Example - limit to 10 mirrors

sudo pacman-mirrors --fasttrack 10 && sudo pacman -Syyu

Pacman-mirrors will download a status file from the mirror service URL.

From that file you will get 10 random mirrors that have updated software for your current branch.

The 10 mirrors will be sorted by their current response times and written to the mirror list.

Using pacman-mirrors --country

sudo pacman-mirrors --country Costa_Rica && sudo pacman -Syyu

Works like pacman-mirrors --fasttrack, but with the search confined to the country or countries of your choice.

Use a space ( ) or (,) to seperate multiple countries, and an underscore (_) for spaces in a country's name.

sudo pacman-mirrors --country United_Kingdom Ireland Sweden && sudo pacman -Syyu

The above example will create a list of mirrors from those 3 countries and sort them according to response time.

Using pacman-mirrors --interactive

sudo pacman-mirrors --interactive && sudo pacman -Syyu

It works like pacman-mirrors --fasttrack, except it now works in interactive mode. You are be able to choose your preferred mirrors.

Be aware that the result not only is a custom mirrorlist but also a custom mirror file and if present it will always be used when running pacman-mirrors.

Reset custom mirror file and list

To reset a custom mirror file you have 2 options where the latter recreates the custom mirror file:

sudo pacman-mirrors --country all && sudo pacman -Syyu

or

sudo pacman-mirrors --interactive --default && sudo pacman -Syyu

Then you are be able to renew the list!

Synchronizing your database

Your Manjaro system has a database of all the software packages that are available from the official repositories. These repositories are used by pacman to locate and download packages from them for installation. Synchronizing your database after amending the mirrorlist is the final step in this process. Synchronizing will ensure that your system's database is up to date as well as help to avoid any potential problems when downloading software packages going forward.

Remember to syncronize and update system with the new mirror list. To do so enter the following command in the terminal:

sudo pacman -Syyu

Once the /etc/pacman.d/mirrorlist has been reordered and the database synchronized, the desired changes will be in effect (there is no need to reboot your system).

Optional: Inspect the contents of the revised mirrorlist

The syntax of the command to open the mirrorlist file is:

sudo [text editor] /etc/pacman.d/mirrorlist

For example, if you wish to view the mirrorlist file within the terminal using nano (a standard terminal-based text editor) then enter:

sudo nano /etc/pacman.d/mirrorlist

Otherwise - if you have installed the full version of Manjaro (i.e. not the NET-Edition) - you may find it easier to use the pre-installed gedit text editor instead. This will open the mirrorlist file up as a document, making it easier to read and edit. To use gedit instead, the command is:

sudo gedit /etc/pacman.d/mirrorlist

Once the contents of the mirrorlist have been viewed, close the file by:

  • nano: Press CTRL and 'x' to exit, or
  • gedit: Close the window.

See Also