Set Up Arch Linux Mirrors
To ensure fast package updates, it's important to set up optimized mirrors for Arch Linux. This guide covers three methods to configure your mirrors:
- Reflector: An automated tool for finding and ranking mirrors (recommended)
- Mirrorlist Generator: Manual mirror selection from the Arch website
- Rankmirrors: Rank mirrors based on speed with
pacman-contrib
Prerequisites
You’ll need sudo
privileges to edit the mirrorlist and install packages.
1. Using Reflector for Automated Mirror Ranking (recommended)
reflector
automatically updates, filters, and ranks mirrors based on speed and other criteria.
- Install Reflector Install
reflector
:
sudo pacman -S reflector
- Backup Your Mirrorlist Backup your current mirrorlist:
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
- Use Reflector to Rank Mirrors Run
reflector
to find and rank mirrors. Customize it based on your location:
sudo reflector --country 'United States' --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
--country 'United States'
: Replace with your country.--age 12
: Only use mirrors synced within the last 12 hours.--protocol https
: Use HTTPS mirrors.--sort rate
: Rank by speed.Verify the MirrorlistCheck the updated mirrorlist:
cat /etc/pacman.d/mirrorlist
Automate Reflector (Optional)To automate mirror updates, configure a
reflector
systemd service:Create a configuration file:
bashsudo nano /etc/xdg/reflector/reflector.conf
Example content:
--country 'United States' --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
Enable the systemd service:
bashsudo systemctl enable --now reflector.service
Update Package Databases
After ranking mirrors, refresh the database:
sudo pacman -Syy
2. Using the Arch Linux Mirrorlist Generator
- Open the Mirrorlist Generator
Visit the official Arch Linux mirrorlist generator.
- Select Your Country or Region
Choose the country or region closest to you.
Customize Your Mirrorlist
- Protocol: HTTPS is preferred, but you can also select HTTP.
- Status: Choose mirrors synced within the last 24 hours for the latest updates.
- IPv4/IPv6: Select based on your network setup.
Generate and Download the Mirrorlist
Click "Generate Mirrorlist" and either copy the list or download the file.
- Backup Your Current Mirrorlist
Backup your existing mirrorlist before making changes:
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
Replace the Mirrorlist
- Open the mirrorlist file and replace its contents with the newly generated list:
bashsudo nano /etc/pacman.d/mirrorlist
- Uncomment all mirrors by running this command:
bashsudo sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist
Update Package Databases
Refresh your package database:
sudo pacman -Syy
3. Using Rankmirrors from Pacman-Contrib
rankmirrors
helps you rank mirrors by speed. It’s part of the pacman-contrib
package.
- Install
pacman-contrib
Install the package:
sudo pacman -S pacman-contrib
- Backup Your Mirrorlist
Always back up your mirrorlist first:
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
- Uncomment All Mirrors
Uncomment all mirrors in your mirrorlist:
sudo nano /etc/pacman.d/mirrorlist
Or
use this command to do it automatically:
sudo sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist
- Rank the Mirrors
Rank the mirrors and save the top 10:
rankmirrors -n 10 /etc/pacman.d/mirrorlist | sudo tee /etc/pacman.d/mirrorlist
- Update Package Databases
Update your database after ranking the mirrors:
sudo pacman -Syy