Mirrors: Difference between revisions

From ArchWiki
(update interlanguage links)
m (Update interlanguage links)
 
(19 intermediate revisions by 8 users not shown)
Line 6: Line 6:
[[pt:Mirrors]]
[[pt:Mirrors]]
[[ru:Mirrors]]
[[ru:Mirrors]]
[[tr:Mirrors]]
[[zh-hans:Mirrors]]
[[zh-hans:Mirrors]]
{{Related articles start}}
{{Related articles start}}
{{Related|Unofficial mirrors}}
{{Related|Unofficial mirrors}}
{{Related|pacman}}
{{Related|pacman}}
{{Related|DeveloperWiki:NewMirrors}}
{{Related articles end}}
{{Related articles end}}


Line 28: Line 30:
== Enabling a specific mirror ==
== Enabling a specific mirror ==


To enable mirrors, edit {{ic|/etc/pacman.d/mirrorlist}} and locate your geographic region. Uncomment mirrors you would like to use.
To enable mirrors, edit {{ic|/etc/pacman.d/mirrorlist}} and locate your geographic region. Uncomment mirrors you would like to use.


Example:
For example:


  # Any
  ## Worldwide
  # Server = <nowiki>http://mirrors.kernel.org/archlinux/$repo/os/$arch</nowiki>
#Server = <nowiki>https://geo.mirror.pkgbuild.com/$repo/os/$arch</nowiki>
  '''Server = <nowiki>https://mirrors.kernel.org/archlinux/$repo/os/$arch</nowiki>'''
  #Server = <nowiki>http://mirror.rackspace.com/archlinux/$repo/os/$arch</nowiki>
  '''Server = <nowiki>https://mirror.rackspace.com/archlinux/$repo/os/$arch</nowiki>'''


See [[#Sorting mirrors]] for tools that help choosing mirrors.
See [[#Sorting mirrors]] for tools that help choosing mirrors.


{{Tip|
{{Tip|Uncomment 5 favorite mirrors and place them at the top of the mirrorlist file. That way it is easy to find them and move them around if the first mirror on the list has problems. It also makes merging mirrorlist updates easier.}}
* Uncomment 5 favorite mirrors and place them at the top of the mirrorlist file. That way it is easy to find them and move them around if the first mirror on the list has problems. It also makes merging mirrorlist updates easier.
 
* HTTP mirrors are faster than FTP due to [[Wikipedia:HTTP persistent connection|persistent HTTP connection]]: with FTP, a new connection to server has to be established each time ''pacman'' requests a package to be downloaded, which results in a brief pause.
It is also possible to specify mirrors in {{ic|/etc/pacman.conf}}. For the ''core'' repository, the default setup is:
}}


It is also possible to specify mirrors in {{ic|/etc/pacman.conf}}. For the ''[core]'' repository, the default setup is:
  [core]
  [core]
  Include = /etc/pacman.d/mirrorlist
  Include = /etc/pacman.d/mirrorlist


To use the ''HostEurope'' mirror as a default mirror, add it before the {{ic|Include}} line:
To use the ''kernel.org'' mirror as a default mirror, add it before the {{ic|Include}} line:
 
  [core]
  [core]
  '''Server = <nowiki>http://ftp.hosteurope.de/mirror/ftp.archlinux.org/core/os/$arch</nowiki>'''
  '''Server = <nowiki>https://mirrors.kernel.org/archlinux/$repo/os/$arch</nowiki>'''
  Include = /etc/pacman.d/mirrorlist
  Include = /etc/pacman.d/mirrorlist


pacman will now try to connect to this mirror first. Proceed to do the same for ''[testing]'', ''[extra]'', and ''[community]'', if applicable.
pacman will now try to connect to this mirror first. Proceed to do the same for ''core-testing'', ''extra'', and ''extra-testing'', if applicable.


{{Note|If mirrors have been stated directly in {{ic|pacman.conf}}, remember to use the same mirror for all repositories. Otherwise packages that are incompatible to each other may be installed, like linux from ''[core]'' and an older kernel module from ''[extra]''.}}
{{Warning|If mirrors have been stated directly in {{ic|pacman.conf}}, remember to use the same mirror for all repositories. Otherwise this would result in a [[partial upgrade]] as packages that are incompatible with each other may be installed, like {{Pkg|linux}} from ''core'' and an older kernel module from ''extra''.}}


=== Force pacman to refresh the package lists ===
=== Force pacman to refresh the package lists ===
Line 61: Line 63:


After creating/editing {{ic|/etc/pacman.d/mirrorlist}}, issue the following command:
After creating/editing {{ic|/etc/pacman.d/mirrorlist}}, issue the following command:
  # pacman -Syyu
  # pacman -Syyu


Passing two {{ic|--refresh}}/{{ic|-y}} flags forces pacman to refresh all package lists even if they are considered to be up to date. Issuing {{ic|pacman -Syyu}} is an unnecessary waste of bandwidth in most cases, but can sometimes fix issues when switching from a broken mirror to a working mirror. See also [https://bbs.archlinux.org/viewtopic.php?id=163124 Is -Syy safe?].
Passing two {{ic|--refresh}}/{{ic|-y}} flags forces pacman to refresh all package lists even if they are considered to be up to date.  
 
{{Note|1=Issuing {{ic|pacman -Syyu}} is an unnecessary waste of bandwidth in most cases, but can sometimes fix issues when switching from a broken mirror to a working mirror. See also [https://bbs.archlinux.org/viewtopic.php?id=163124 Is -Syy safe?].}}


{{Warning|In most cases if you force refresh the pacman database, you will want to force downgrade any potentially too-new packages to correspond to the versions offered by the new mirror. This prevents issues where packages are inconsistently upgraded, leading to a partial update.
{{Warning|In most cases if you force refresh the pacman database, you will want to force downgrade any potentially too-new packages to correspond to the versions offered by the new mirror. This prevents issues where packages are inconsistently upgraded, leading to a partial update.
  # pacman -Syyuu
  # pacman -Syyuu
This is not necessary when using [https://archlinux.org/mirrors/status/#successful successfully syncing mirrors] or checking timestamp of mirror's '''lastsync''' file to ensure package lists are up to date.
 
This is not necessary when using [https://archlinux.org/mirrors/status/#successful successfully syncing mirrors] or checking timestamp of mirror's {{ic|lastsync}} file to ensure package lists are up to date.
}}
}}


Line 91: Line 98:


* Edit {{ic|mirrorlist.backup}} and uncomment the servers to be tested
* Edit {{ic|mirrorlist.backup}} and uncomment the servers to be tested
* If the servers in the file are grouped by country, one can extract all the servers of a specific country by using: {{bc|1=$ awk '/^## ''Country Name''$/{f=1; next}f==0{next}/^$/{exit}{print substr($0, 1);}' /etc/pacman.d/mirrorlist.backup}}
* If the servers in the file are grouped by country, one can extract all the servers of a specific country by using: {{bc|1=$ awk '/^## ''Country Name''$/{f=1; next}f==0{next}/^$/{exit}{print substr($0, 1);}' /etc/pacman.d/mirrorlist.backup}}
* To uncomment every mirror, run the following {{ic|sed}} line: {{bc|# sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist.backup}}
* To uncomment every mirror, run the following {{ic|sed}} line: {{bc|# sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist.backup}}
* Finally, rank the mirrors, here with the operand {{ic|-n 6}} to only output the 6 fastest mirrors: {{bc|# rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist}}
* Finally, rank the mirrors, here with the operand {{ic|-n 6}} to only output the 6 fastest mirrors: {{bc|# rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist}}


==== Fetching and ranking a live mirror list ====
==== Fetching and ranking a live mirror list ====


In order to start with a shortlist of up-to-date mirrors based in some countries and feed it to ''rankmirrors'' one can fetch the list from the ''Pacman Mirrorlist Generator''.
In order to start with a shortlist of up-to-date mirrors based in some countries and feed it to ''rankmirrors'' one can fetch the list from the ''Pacman Mirrorlist Generator''. The command below pulls the up-to-date mirrors in either ''France'' or the ''United Kingdom'' which support the ''https'' protocol, it uncomments the servers in the list and then ranks them and outputs the 5 fastest.
The command below pulls the up-to-date mirrors in either ''France'' or the ''United Kingdom'' which support the ''https'' protocol, it uncomments the servers in the list and then ranks them and outputs the 5 fastest.


  $ 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 -
  $ 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 -
Line 109: Line 112:
Existing tools:
Existing tools:


{{App|Rate Mirrors|It fetches mirrors, skips outdated/syncing mirrors, then uses info about submarine cables and internet exchanges to jump between countries and find fast mirrors. And it is fast enough to run it before each update. It also supports custom mirror lists fed via stdin.|https://github.com/westandskif/rate-mirrors|{{AUR|rate-mirrors}}, {{AUR|rate-mirrors-bin}}}}
{{App|Rate Mirrors|It fetches mirrors, skips outdated/syncing mirrors, then uses info about submarine cables and internet exchanges to jump between countries and find fast mirrors. And it is fast enough to run it before each update. It also supports custom mirror lists fed via stdin.|https://github.com/westandskif/rate-mirrors|{{AUR|rate-mirrors}}}}


=== Server-side ranking ===
=== Server-side ranking ===
Line 117: Line 120:
Another popular alternative is the following tool:
Another popular alternative is the following tool:


{{App|[[Reflector]]|Retrieves the latest mirrorlist from the [https://archlinux.org/mirrors/status/ MirrorStatus] page, filters and sorts them by speed and overwrites {{ic|/etc/pacman.d/mirrorlist}}|https://xyne.dev/projects/reflector/|{{pkg|reflector}}}}
{{App|[[Reflector]]|Retrieves the latest mirrorlist from the [https://archlinux.org/mirrors/status/ MirrorStatus] page, filters and sorts them by speed and overwrites {{ic|/etc/pacman.d/mirrorlist}}. Provides automation with a systemd service and timer.|https://xyne.dev/projects/reflector/|{{pkg|reflector}}}}


== Troubleshooting ==
== Troubleshooting ==


=== Missing mirrorlist ===
=== Missing mirrorlist ===
{{Expansion|Mirror list is also distributed via {{Pkg|pacman-mirrorlist}}, therefore there should be {{ic|mirrorlist.pacnew}} within the directory and if not, you can just reinstall the package again, and the mirrorlist be installed because it no longer exists, this is more simple than using curl.}}


In case you encounter the following error:
In case you encounter the following error:
  error: config file /etc/pacman.d/mirrorlist could not be read: No such file or directory
  error: config file /etc/pacman.d/mirrorlist could not be read: No such file or directory


Get the mirrorlist directly from the website:
Get the mirrorlist directly from the website:
  # curl -o /etc/pacman.d/mirrorlist <nowiki>https://archlinux.org/mirrorlist/all/</nowiki>
  # curl -o /etc/pacman.d/mirrorlist <nowiki>https://archlinux.org/mirrorlist/all/</nowiki>


Be sure to uncomment a preferred mirror as described above, then:
Be sure to uncomment a preferred mirror as described in [[#Enabling a specific mirror]], then:
 
  # pacman -Syu pacman-mirrorlist
  # pacman -Syu pacman-mirrorlist


=== Misbehaving mirrors ===
=== Misbehaving mirrors ===


If you are certain a mirror is not operating properly and that is not reflected on the [https://archlinux.org/mirrors/status/ mirrors status page], change the mirror and consider [[Bug_reporting_guidelines#Opening_a_bug|opening a bug report]]. For mirrors the issue should be opened in the "Arch Linux" project (see the list just below the log-in box, or search for "switch" on the page), with task type "Bug report", category "Mirrors".
If you are certain a mirror is not operating properly and that is not reflected on the [https://archlinux.org/mirrors/status/ mirrors status page], change the mirror and consider [[Bug reporting guidelines#Opening a bug|opening a bug report]]. For mirrors the issue should be opened in the [https://gitlab.archlinux.org/archlinux/arch-mirrors/-/issues arch-mirrors project at the Arch Linux GitLab]. You may also send a mail to [mailto:mirrors@archlinux.org mirrors@archlinux.org].


== See also ==
== See also ==
* [https://github.com/archlinux/archweb/blob/master/mirrors/views/mirrorlist.py GitHub archweb mirrorlist.py] - source code of the archweb mirrorlist generator
* [https://github.com/archlinux/archweb/blob/master/mirrors/views/mirrorlist.py GitHub archweb mirrorlist.py] - source code of the archweb mirrorlist generator

Latest revision as of 13:35, 17 February 2024

This page is a guide to selecting and configuring your mirrors, and a listing of current available mirrors.

Official mirrors

The official Arch Linux mirror list is available from the pacman-mirrorlist package. To get an even more up-to-date list of mirrors, use the Pacman Mirrorlist Generator page.

Check the status of the mirrors by visiting the Mirror Status page. It is recommended to only use mirrors that are up to date, i.e. not out of sync.

If you want your mirror to be added to the official list, see DeveloperWiki:NewMirrors. In the meantime, add it to the Unofficial mirrors article.

IPv6-ready mirrors

The Pacman Mirrorlist Generator can also be used to find a list of current IPv6 mirrors.

Enabling a specific mirror

To enable mirrors, edit /etc/pacman.d/mirrorlist and locate your geographic region. Uncomment mirrors you would like to use.

For example:

## Worldwide
#Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
#Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch
Server = https://mirror.rackspace.com/archlinux/$repo/os/$arch

See #Sorting mirrors for tools that help choosing mirrors.

Tip: Uncomment 5 favorite mirrors and place them at the top of the mirrorlist file. That way it is easy to find them and move them around if the first mirror on the list has problems. It also makes merging mirrorlist updates easier.

It is also possible to specify mirrors in /etc/pacman.conf. For the core repository, the default setup is:

[core]
Include = /etc/pacman.d/mirrorlist

To use the kernel.org mirror as a default mirror, add it before the Include line:

[core]
Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch
Include = /etc/pacman.d/mirrorlist

pacman will now try to connect to this mirror first. Proceed to do the same for core-testing, extra, and extra-testing, if applicable.

Warning: If mirrors have been stated directly in pacman.conf, remember to use the same mirror for all repositories. Otherwise this would result in a partial upgrade as packages that are incompatible with each other may be installed, like linux from core and an older kernel module from extra.

Force pacman to refresh the package lists

Mirrors can be out of sync and the package list from the old mirror may not correspond to the package list of the new mirror, even though the dates of the lists may suggest that they do.

After creating/editing /etc/pacman.d/mirrorlist, issue the following command:

# pacman -Syyu

Passing two --refresh/-y flags forces pacman to refresh all package lists even if they are considered to be up to date.

Note: Issuing pacman -Syyu is an unnecessary waste of bandwidth in most cases, but can sometimes fix issues when switching from a broken mirror to a working mirror. See also Is -Syy safe?.
Warning: In most cases if you force refresh the pacman database, you will want to force downgrade any potentially too-new packages to correspond to the versions offered by the new mirror. This prevents issues where packages are inconsistently upgraded, leading to a partial update.
# pacman -Syyuu

This is not necessary when using successfully syncing mirrors or checking timestamp of mirror's lastsync file to ensure package lists are up to date.

Sorting mirrors

When downloading packages, pacman uses the mirrors in the order they are listed in /etc/pacman.d/mirrorlist. The order servers appear in the list sets their priority.

It is not optimal to only rank mirrors based on speed since the fastest servers might be out-of-sync. Instead, make a list of mirrors sorted by their speed, then remove those from the list that are out of sync according to their status.

It is recommended to regularly repeat this process to keep the list of mirrors up-to-date.

List by speed

Ranking an existing mirror list

The pacman-contrib package provides a Bash script, /usr/bin/rankmirrors, which can be used to rank the mirrors according to their connection and opening speeds to take advantage of using the fastest local mirror.

Back up the existing /etc/pacman.d/mirrorlist:

# cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup

To prepare mirrorlist.backup for ranking with rankmirrors, the following actions can be carried out:

  • Edit mirrorlist.backup and uncomment the servers to be tested
  • If the servers in the file are grouped by country, one can extract all the servers of a specific country by using:
    $ awk '/^## Country Name$/{f=1; next}f==0{next}/^$/{exit}{print substr($0, 1);}' /etc/pacman.d/mirrorlist.backup
  • To uncomment every mirror, run the following sed line:
    # sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist.backup
  • Finally, rank the mirrors, here with the operand -n 6 to only output the 6 fastest mirrors:
    # rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist

Fetching and ranking a live mirror list

In order to start with a shortlist of up-to-date mirrors based in some countries and feed it to rankmirrors one can fetch the list from the Pacman Mirrorlist Generator. The command below pulls the up-to-date mirrors in either France or the United Kingdom which support the https protocol, it uncomments the servers in the list and then ranks them and outputs the 5 fastest.

$ 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 -
Tip: This procedure can be done interactively by navigating to https://archlinux.org/mirrorlist with any text-based browser, for example elinks(1).

Existing tools:

Rate Mirrors — It fetches mirrors, skips outdated/syncing mirrors, then uses info about submarine cables and internet exchanges to jump between countries and find fast mirrors. And it is fast enough to run it before each update. It also supports custom mirror lists fed via stdin.

https://github.com/westandskif/rate-mirrors || rate-mirrorsAUR

Server-side ranking

The official Pacman Mirrorlist Generator provides an easy way to obtain a ranked list of mirrors. Because all ranking is done on a single server that takes multiple factors into account, the amount of load on the mirrors and the clients is significantly lower compared to ranking on each individual client.

Another popular alternative is the following tool:

Reflector — Retrieves the latest mirrorlist from the MirrorStatus page, filters and sorts them by speed and overwrites /etc/pacman.d/mirrorlist. Provides automation with a systemd service and timer.

https://xyne.dev/projects/reflector/ || reflector

Troubleshooting

Missing mirrorlist

This article or section needs expansion.

Reason: Mirror list is also distributed via pacman-mirrorlist, therefore there should be mirrorlist.pacnew within the directory and if not, you can just reinstall the package again, and the mirrorlist be installed because it no longer exists, this is more simple than using curl. (Discuss in Talk:Mirrors)

In case you encounter the following error:

error: config file /etc/pacman.d/mirrorlist could not be read: No such file or directory

Get the mirrorlist directly from the website:

# curl -o /etc/pacman.d/mirrorlist https://archlinux.org/mirrorlist/all/

Be sure to uncomment a preferred mirror as described in #Enabling a specific mirror, then:

# pacman -Syu pacman-mirrorlist

Misbehaving mirrors

If you are certain a mirror is not operating properly and that is not reflected on the mirrors status page, change the mirror and consider opening a bug report. For mirrors the issue should be opened in the arch-mirrors project at the Arch Linux GitLab. You may also send a mail to mirrors@archlinux.org.

See also