Mirrors

From ArchWiki
Jump to: navigation, search

Related articles

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, (manually or by using rankmirrors) issue the following command:

# pacman -Syyu

Passing two --refresh or -y flags forces pacman to refresh all package lists even if they are considered to be up to date. Issuing pacman -Syyu whenever changing to a new mirror is good practice and will avoid possible issues. See also Is -Syy safe?.

Sorting mirrors

When downloading packages pacman uses the mirrors in the order they are in /etc/pacman.d/mirrorlist. To set a priority to mirrors, the mirrorlist file has to be sorted manually or using a script.

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 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 /etc/pacman.d/mirrorlist up to date.

List by speed

The pacman 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

Edit /etc/pacman.d/mirrorlist.backup and uncomment mirrors for testing with rankmirrors.

Optionally run the following sed line to uncomment every mirror:

# sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist.backup

Finally, rank the mirrors. Operand -n 6 means only output the 6 fastest mirrors:

# rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist

Run rankmirrors -h for a list of all the available options.

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.

There are multiple scripts automating the update of the mirrorlist from the ranking server:

  • Reflector retrieves the latest mirrorlist from the MirrorStatus page, filters the most up-to-date mirrors, sorts them by speed and overwrites the /etc/pacman.d/mirrorlist file.
  • update-pacman-mirrorlistAUR is a minimalistic script that downloads a mirrorlist from a specified ranking server defaulting to the official Pacman Mirrorlist Generator. It also provides an optional systemd timer to manage the mirrorlist automatically without intervention.
  • armrr downloads a ranked mirrorlist for a specific country from the Pacman Mirrorlist Generator and creates a backup of the previous mirrorlist.

List mirrors only for a specific country

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 mirrorlist.pacnew exist, the file creates after installation of the pacman-mirrorlist update.

Cnt="China";
awk -v GG=$Cnt '{if(match($0,GG) != "0")AA="1";if(AA == "1"){if( length($2) != "0"  )print substr($0,2) ;else AA="0"} }' \
 /etc/pacman.d/mirrorlist.pacnew

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

If you get an error stating that the $arch variable is used but not defined, add the following to your /etc/pacman.conf:

Architecture = x86_64
Note: You can also use the values auto and i686 for the Architecture variable.

Unofficial mirrors

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

Austria

China

Telecom

Unicom

Cernet

France

Germany

Indonesia

Iran

Italy

Japan

Malaysia

New Zealand

Poland

Russia

South Africa

Sweden

Thailand

United States

Sourceforge (old ISOs)