Reflector
Reflector is a Python script which can retrieve the latest mirror list from the Arch Linux Mirror Status page, filter the most up-to-date mirrors, sort them by speed and overwrite the file /etc/pacman.d/mirrorlist
.
Installation
Install the reflector package.
Usage
- In the following examples,
/etc/pacman.d/mirrorlist
will be overwritten. Make a backup before proceeding. - Make sure the resulting
/etc/pacman.d/mirrorlist
does not contain entries that you consider untrustworthy before syncing or updating with pacman.
To see all of the available options, run the following command:
$ reflector --help
Examples
See reflector(1) § EXAMPLES. Examples overwriting /etc/pacman.d/mirrorlist
need to be run as root.
--country 'France,Germany,'
.[1]
Automation
systemd service
Reflector ships with a reflector.service
. The service will run reflector with the parameters specified in /etc/xdg/reflector/reflector.conf
. The default options in this file should serve as a good starting point and example.
For example, to select the 5 most up-to-date mirrors from France and Germany that support HTTPS and overwrite /etc/pacman.d/mirrorlist
, use
/etc/xdg/reflector/reflector.conf
--save /etc/pacman.d/mirrorlist --country France,Germany --protocol https --latest 5
Enable reflector.service
to run Reflector on boot. To run it immediately, start the service.
reflector.service
depends on a network wait service to be configured via network-online.target.systemd timer
Reflector provides a systemd timer (reflector.timer
) that starts the #systemd service reflector.service
weekly. The schedule can be changed by editing reflector.timer
.
First edit the configuration file as described in #systemd service. After you have updated the configuration file, start and enable reflector.timer
.
To refresh the mirrorlist ahead of schedule, start reflector.service
.
pacman hook
You can create a pacman hook that will start reflector.service
and remove the .pacnew file created every time pacman-mirrorlist gets an upgrade.
/etc/pacman.d/hooks/mirrorupgrade.hook
[Trigger] Operation = Upgrade Type = Package Target = pacman-mirrorlist [Action] Description = Updating pacman-mirrorlist with reflector and removing pacnew... When = PostTransaction Depends = reflector Exec = /bin/sh -c 'systemctl start reflector.service; [ -f /etc/pacman.d/mirrorlist.pacnew ] && rm /etc/pacman.d/mirrorlist.pacnew'
Set desired mirror options in /etc/xdg/reflector/reflector.conf
as described in #systemd service.
This is also provided by reflector-mirrorlist-updateAUR.