Updating Archlinux Mirrorlist with Reflector
By default, pacman does not update its own mirrorlist; however, there is the pacman-mirrorlist package which gets updated regularly. But it does not overwrite the actual mirrorlist on updates - that would be bad, because all its entries are commented out by default.
Some people may prefer constant manual intervention here, but I prefer automation.
Reflector can do this manually or via a systemd service. It also reads the configuration file /etc/xdg/reflector/reflector.conf.
The archwiki page lists three methods of automated execution:
- a hook to run after a pacman-mirrorlist update
- a weekly systemd timer
- a daily cron task
While it makes sense to only run reflector when pacman-mirrorlist is updated, I prefer to run it weekly, because servers can drop out or slow down more often than that.
Installation, Configuration, Automation-up-
Here's my edited /etc/xdg/reflector/reflector.conf:
$> grep -vE '^#|^$' /etc/xdg/reflector/reflector.conf --save /etc/pacman.d/mirrorlist --protocol https --country AT,BE,BA,BG,HR,CZ,DK,FI,FR,DE,GR,IS,IE,IT,LV,LT,LU,NL,MK,NO,PL,PT,RO,RS,SK,SI,ES,SE,CH,GB --latest 200 --sort score
(that's most of Europe)
Now I just start the service, check its status, and the content of the newly created mirrorlist:
$> sudo systemctl start reflector.service $> sudo systemctl status reflector.service $> less /etc/pacman.d/mirrorlist
All is good - start the timer & check its status:
$> sudo systemctl start reflector.timer $> systemctl status reflector.timer
Again, all good. Install it:
$> sudo systemctl enable reflector.timer Created symlink /etc/systemd/system/timers.target.wants/reflector.timer → /usr/lib/systemd/system/reflector.timer.
Name Resolution Required-up-
In the past, reflector did not have its own systemd service and I wrote my own. I had problems with reflector starting before the WWW was available (name resolution). I hope the newly included service does not have that problem. It includes:
$> grep ^After /usr/lib/systemd/system/reflector.service After=network-online.target nss-lookup.target
man systemd.special says:
A target that should be used as synchronization point for all host/network name service lookups. Note that this is independent of UNIX user/group name lookups for which nss-user-lookup.target should be used. All services for which the availability of full host/network name resolution is essential should be ordered after this target, but not pull it in.
Sounds about correct, I have to remember that.