Setup Pacman Mirrors on Arch Linux

28/12/2020
Chưa phân loại
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 https://www.archlinux.org/mirrorlist/ 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

https://www.archlinux.org/mirrorlist/all/

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.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

[NGINX] Giới hạn số lượng request trong một khoảng thời gian

Việc giới hạn số lượng request của một client trong một khoảng thời gian sẽ giảm được rủi...
30/12/2020

Best Music Players for elementary OS

As a newbie-friendly distro, elementary OS complies the aforementioned features. At the current age, leisure has always...
29/12/2020

Thiết lập và thay đổi MariaDB 10.4.x Root Password

Khác với những version trước đây, MariaDB 10.4 bản ổn định có thêm nhiều cải tiến. Một trong...
30/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Dịch Vụ Xây Dựng Hệ Thống Peering Với Internet Exchange (IXP)
04/04/2025

Dịch Vụ Triển Khai VPN Site-to-Site & Remote Access
04/04/2025

Dịch Vụ Thiết Lập Hệ Thống Tường Lửa (Firewall)
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ảo Hóa & Cloud
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ceph
04/04/2025