Difference between revisions of "Mirrors"

From ArchWiki
Jump to: navigation, search
(List mirrors only for a specific country: removes the # before Server in the output)
(Undo revision 531158 by Hubcaps (talk) Output will contain a single 'Server=' entry, thus inept for use with rankmirrors.)
 
(33 intermediate revisions by 13 users not shown)
Line 64: Line 64:
 
  # pacman -Syyu
 
  # pacman -Syyu
  
Passing two {{ic|--refresh}} or {{ic|-y}} flags forces pacman to refresh all package lists even if they are considered to be up to date. Issuing {{ic|pacman -Syyu}} ''whenever changing to a new mirror'' is good practice and will avoid possible issues. 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. 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.
 +
# pacman -Syyuu
 +
This is not necessary when using timestamps to ensure the mirrors are only upgraded.
 +
}}
  
 
== Sorting mirrors ==
 
== Sorting mirrors ==
  
When downloading packages pacman uses the mirrors in the order they are in {{ic|/etc/pacman.d/mirrorlist}}. To set a priority to mirrors, the mirrorlist file has to be sorted manually or using a script.
+
When downloading packages, pacman uses the mirrors in the order they are listed in {{ic|/etc/pacman.d/mirrorlist}}. The order servers appear in the list sets their priority.
  
It is not a good idea to just use the fastest mirrors, since the fastest mirrors might be out of sync. Instead, make a list of mirrors sorted by their [[#List by speed|speed]], then remove those from the list that are out of sync according to their [https://www.archlinux.org/mirrors/status/ status].
+
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 [[#List by speed|speed]], then remove those from the list that are out of sync according to their [https://www.archlinux.org/mirrors/status/ status].
  
It is recommended to repeat this process before every system upgrade to keep {{ic|/etc/pacman.d/mirrorlist}} up to date.
+
It is recommended to repeat this process before every system upgrade to keep the list of mirrors up-to-date.
  
 
=== List by speed ===
 
=== List by speed ===
 
+
====Ranking an existing mirror list====
The {{Pkg|pacman}} package provides a Bash script, {{ic|/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.
+
The {{Pkg|pacman-contrib}} package provides a Bash script, {{ic|/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 {{ic|/etc/pacman.d/mirrorlist}}:
 
Back up the existing {{ic|/etc/pacman.d/mirrorlist}}:
Line 82: Line 87:
 
  # cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
 
  # cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
  
Edit {{ic|/etc/pacman.d/mirrorlist.backup}} and uncomment mirrors for testing with {{ic|rankmirrors}}.
+
To prepare {{ic|mirrorlist.backup}} for ranking with ''rankmirrors'', the following actions can be carried out:
 +
 
 +
* Edit {{ic|mirrorlist.backup}} and uncomment the servers to be tested
  
Optionally run the following {{ic|sed}} line to uncomment every mirror:
+
* 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}f==0{next}/^$/{exit}{print substr($0, 2)}' /etc/pacman.d/mirrorlist.backup}}
  
# 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. Operand {{ic|-n 6}} means only output the 6 fastest mirrors:
+
Finally, rank the mirrors, here with the operand {{ic|-n 6}} to only output the 6 fastest mirrors:
  
 
  # rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
 
  # rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
  
Run {{ic|rankmirrors -h}} for a list of all the available options.
+
====Fetching and ranking a live mirror list====
  
=== Server-side ranking ===
+
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 official [https://www.archlinux.org/mirrorlist/ 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.
+
$ curl -s "https://www.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 multiple scripts automating the update of the mirrorlist from the ranking server:
+
{{Tip|This procedure can be done interactively by navigating to {{ic|1=https://www.archlinux.org/mirrorlist}} with any text-based browser, for example {{man|1|elinks}}.}}
  
* {{App|[[Reflector]]|Retrieves the latest mirrorlist from the [https://www.archlinux.org/mirrors/status/ MirrorStatus] page, filters the most up-to-date mirrors, sorts them by speed and overwrites {{ic|/etc/pacman.d/mirrorlist}}|https://xyne.archlinux.ca/projects/reflector/|{{pkg|reflector}}}}
+
=== Server-side ranking ===
* {{App|armrr|Downloads a ranks mirrorlist for specific countries from the [https://www.archlinux.org/mirrorlist/ Pacman Mirrorlist Generator]|https://github.com/spurge/armrr|no package}}
 
  
=== List mirrors only for a specific country ===
+
The official [https://www.archlinux.org/mirrorlist/ 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.
  
Can be useful to automate update of the mirror list only for a specific countries instead of making a speed test each time. Assumed that {{ic|mirrorlist.pacnew}} exist, the file creates after installation of the {{Pkg|pacman-mirrorlist}} update.
+
Another popular alternative is the following tool:
  
{{bc|1=awk '/^## United Kingdom$/ {f=1} f==0 {next} /^$/ {exit} {print substr($0, 2)}' /etc/pacman.d/mirrorlist.pacnew}}
+
{{App|[[Reflector]]|Retrieves the latest mirrorlist from the [https://www.archlinux.org/mirrors/status/ MirrorStatus] page, filters and sorts them by speed and overwrites {{ic|/etc/pacman.d/mirrorlist}}|https://xyne.archlinux.ca/projects/reflector/|{{pkg|reflector}}}}
  
 
== Troubleshooting ==
 
== Troubleshooting ==
Line 141: Line 148:
  
 
'''Cernet'''
 
'''Cernet'''
 +
*http://mirror.hust.edu.cn/archlinux/ - ''Huazhong University of Science and Technology Mirror (HUSTMirror)''
 
*http://mirrors.geekpie.org/archlinux/ - ''Geek Pie Association @ ShanghaiTech University''
 
*http://mirrors.geekpie.org/archlinux/ - ''Geek Pie Association @ ShanghaiTech University''
 
*http://ftp.sjtu.edu.cn/archlinux/ - ''Shanghai Jiaotong University(Legacy)''
 
*http://ftp.sjtu.edu.cn/archlinux/ - ''Shanghai Jiaotong University(Legacy)''
*https://mirrors.sjtug.org/archlinux/ - ''Shanghai Jiaotong University Linux User Group''
+
*https://mirrors.sjtug.sjtu.edu.cn/archlinux/ - ''Shanghai Jiaotong University Linux User Group''
 
*http://mirrors.4.tuna.tsinghua.edu.cn/archlinux/ ''(ipv4 only)''
 
*http://mirrors.4.tuna.tsinghua.edu.cn/archlinux/ ''(ipv4 only)''
 
*http://mirrors.6.tuna.tsinghua.edu.cn/archlinux/ ''(ipv6 only)''
 
*http://mirrors.6.tuna.tsinghua.edu.cn/archlinux/ ''(ipv6 only)''
Line 186: Line 194:
  
 
*http://mirror.ece.auckland.ac.nz/archlinux/  ''NZ only''
 
*http://mirror.ece.auckland.ac.nz/archlinux/  ''NZ only''
 +
*https://mirror.fsmg.org.nz/archlinux/ - ''Free Software Mirror Group''
  
 
=== Poland ===
 
=== Poland ===
Line 232: Line 241:
  
 
* http://sourceforge.net/projects/archlinux/files/ - ''ISO files only; Does not have any releases since 2006. Use it only for getting older ISOs.''
 
* http://sourceforge.net/projects/archlinux/files/ - ''ISO files only; Does not have any releases since 2006. Use it only for getting older ISOs.''
 +
 +
== See also ==
 +
* [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 18:24, 16 August 2018

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 on the main site.

Check the status of the Arch 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 list at the end of this page.

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.

Example:

# Any
# Server = ftp://mirrors.kernel.org/archlinux/$repo/os/$arch
Server = http://mirrors.kernel.org/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's 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 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 /etc/pacman.conf. For the [core] repository, the default setup is:

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

To use the HostEurope mirror as a default mirror, add it before the Include line:

[core]
Server = ftp://ftp.hosteurope.de/mirror/ftp.archlinux.org/core/os/$arch
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.

Note: If mirrors have been stated directly in 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].

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. 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 timestamps to ensure the mirrors are only upgraded.

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 repeat this process before every system upgrade 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}f==0{next}/^$/{exit}{print substr($0, 2)}' /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://www.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://www.archlinux.org/mirrorlist with any text-based browser, for example elinks(1).

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

https://xyne.archlinux.ca/projects/reflector/ || reflector

Troubleshooting

In the unlikely scenario that you are without any configured mirrors and pacman-mirrorlist is not installed, run the following command:

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

Be sure to uncomment a preferred mirror as described above, then:

# pacman -Syu pacman-mirrorlist

Unofficial mirrors

These mirrors are not listed in /etc/pacman.d/mirrorlist.

Austria

Canada

China

Telecom

Unicom

Cernet

France

Indonesia

Iran

Italy

Japan

Malaysia

Netherlands

New Zealand

Poland

Russia

South Africa

Sweden

Thailand

Turkey

United States

Sourceforge (old ISOs)

See also