Arch Linux

Setup Pacman Mirrors on Arch Linux

In this article I will show you how to setup Pacman mirrors on Arch Linux. Let’s get started.

What is an Arch Linux Mirror?

Like all the other Linux distributions such as Ubuntu, Arch Linux also has an official package repository. It is hosted on the official Arch Linux server. To save bandwidth and reduce the cost, to increase the download speed and response time, the official package repository is copied to different server in different parts of the world. So people close to certain geographical location can use that server instead the official Arch Linux server as they are synced with the official Arch Linux package repository.

Each of these servers that keeps a copy of the official Arch Linux package repository is called a mirror.

The Pacman Mirror Configuration File

Arch Linux package manager Pacman keeps it’s mirror list in /etc/pacman.d/mirrorlist file. To change Pacman mirrors, you must modify this file.

Generating a mirrorlist File for Specific Geographical Location

You can generate a mirrorlist file for specific geographical location using the official Arch Linux website.

Go to and you should see the following page as shown in the screenshot below.

You can also use the mirrorlist generator wizard as marked in the screenshot below.

First select your country.

Then check either http or https or both (http and https) in the Protocol section depending on your need.

Then select the IP version. IPv4 is available in every country, IPv6 may not be available. You may select both.

Finally click on Generate List button.

A mirrorlist file should be generate as you can see in the screenshot below.

Now press <Ctrl> + s and save the file as mirrorlist.txt

It is saved.

Now open the file with any text editor.

$ nano ~/Downloads/mirrorlist.txt

Remove the hash (#) sign from the line that starts with Server =

NOTE: If you have multiple lines starting with Server = , then remove the hash (#) sign from the lines that you want to add as Pacman mirror, leave the rests as it is.

Once you’re done, save the file.

Now replace /etc/pacman.d/mirrorlist with this file with the following command:

$ sudo mv -v ~/Downloads/mirrorlist.txt /etc/pacman.d/mirrorlist

The file is moved.

Now update the Pacman package repository cache with the following command:

$ sudo pacman -Syy

The Pacman package repository cache should be updated and as you can see from the marked section of the screenshot below, I am getting 10 times more speed than usual. FYI my usual download speed is 128 KBps.

Finding the Fastest Arch Linux Mirror

At times just setting a geographically closer Arch Linux mirror is not enough. So Before you set an Arch Linux mirror, you should check and find out the fastest mirror on your current ISPs network. Thanks to Arch Linux, Pacman has a built in utility rankmirrors to test and find the fastest mirror for you.

First run the following command to download a mirrorlist file that includes all the available Arch Linux mirrors:

$ curl -o ~/Downloads/mirrorlist

The file should be saved in the Downloads/mirrorlist on your user’s HOME directory.

Now run the following command to uncomment all the mirror lines:

$ sed -i 's/#S/S/g' ~/Downloads/mirrorlist

Now start the check with the following command:

$ rankmirrors ~/Downloads/mirrorlist > ~/Downloads/mirrorlist.fastest

Once the check is complete, the mirrors will be sorted in descending order depending on the download speed in ~/Downloads/mirrorlist.fastest file. It should take a long time to check all the mirrors if your internet connection is slow.

Now replace /etc/pacman.d/mirrorlist file with the ~/Downloads/mirrorlist.fastest file with the following command:

$ sudo mv -v ~/Downloads/mirrorlist.fastest /etc/pacman.d/mirrorlist

File replaced.

Now update the Pacman package repository cache with the following command:

$ sudo pacman -Syy

That’s how you setup Pacman mirrors on Arch Linux. Thanks for reading this article.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.