🐧 Manage your Arch Linux mirrors with Reflector

2020/08/02 by Paulo Pereira

~/categories/Linux #Linux #Arch Linux #Reflector

From the Arch Wiki:

Reflector is a script which can retrieve the latest mirror list from the MirrorStatus page, filter the most up-to-date mirrors, sort them by speed and overwrite the file /etc/pacman.d/mirrorlist.


yay -S reflector
sudo vi /etc/systemd/system/reflector.service
Description=Pacman mirrorlist update
After=network-online.target nss-lookup.target

ExecStart=/usr/bin/reflector --verbose --protocol https --country 'Portugal' --latest 30 --number 20 --sort rate --save /etc/pacman.d/mirrorlist

sudo systemctl daemon-reload
sudo systemctl start reflector.service
sudo systemctl status reflector.service

You can enable the service. I prefer to control when the scripts executes.

Refresh your mirror list

You can force a refresh by starting the service:

sudo systemctl start reflector.service

Or every time the pacman-mirrorlist package is updated by creating a hook:

sudo mkdir -p /etc/pacman.d/hooks/
sudo vi /etc/pacman.d/hooks/mirrorupgrade.hook
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist

Description = Updating pacman-mirrorlist with reflector and removing pacnew...
When = PostTransaction
Depends = reflector
Exec = /bin/sh -c "reflector --verbose --protocol https --country 'Portugal' --latest 30 --number 20 --s
ort rate --save /etc/pacman.d/mirrorlist; rm -f /etc/pacman.d/mirrorlist.pacnew"

Need more help?

Check the reflector help:

reflector --help

Or check the Arch Wiki.