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

Giải pháp đào tạo trực tuyến đơn giản với Wirecast

Giải pháp đào tạo trực tuyến đơn giản Sơ đồ khối hệ thống Mô hình giải pháp cơ bản được...
24/12/2020

How to Split a File of Strings with Awk

The Linux awk command(abbreviated from the names of the developers; Aho, Weinberger, and Kernighan) is a great way to process...
29/12/2020

Hướng dẫn cài đặt MariaDB-10.x trên Ubuntu-18.04

MariaDB là một nhánh của MySQL, là một hệ quản trị cơ sở dữ liệu rất phổ biến ngày nay....
30/12/2020
Bài Viết

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

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024