From ArchWiki
Jump to navigation Jump to search

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.


Install the reflector package.


  • 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 commands, run the following command:

# reflector --help


Verbosely rate and sort the five most recently synchronized mirrors by download speed, and overwrite the file /etc/pacman.d/mirrorlist:

# reflector --verbose --latest 5 --sort rate --save /etc/pacman.d/mirrorlist

Select the 200 most recently synchronized HTTP or HTTPS mirrors, sort them by download speed, and overwrite the file /etc/pacman.d/mirrorlist:

# reflector --latest 200 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist

Select the HTTPS mirrors synchronized within the last 12 hours and located in either France or Germany, sort them by download speed, and overwrite the file /etc/pacman.d/mirrorlist:

# reflector --country France --country Germany --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist


Pacman hook

You can create a pacman hook that will run reflector and remove the .pacnew file created every time pacman-mirrorlist gets an upgrade.

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 --country 'United States' --latest 200 --age 24 --sort rate --save /etc/pacman.d/mirrorlist; rm -f /etc/pacman.d/mirrorlist.pacnew"

Make sure to substitute in your desired arguments for reflector.

systemd service

This is an example of a service unit that waits for the network to be up and online before running reflector:

Description=Pacman mirrorlist update

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


Starting reflector.service will update the mirrorlist. To update the mirrorlist every time the computer boots, enable the service.

Note: For more information on the implementation of the network dependency, see systemd#Running services after the network is up.

systemd timer

If you want to run reflector.service on a weekly basis, create an associated timer. For example:

Description=Run reflector weekly

OnCalendar=Mon *-*-* 7:00:00


And then just enable the reflector.timer.

Reflector-timer package

Install reflector-timerAUR to run reflector weekly.

The default configuration, which can be edited to fit one's needs, is:

### remove an entry if you do not want it as available protocol
PROTOCOL1='-p http'
PROTOCOL2='-p https'
PROTOCOL3='-p ftp'

Be sure to enable reflector.timer.

Cron task

To update the mirrorlist daily, consider the following:


# Get the country thing
/usr/bin/reflector -c "India" -p http --sort rate > /etc/pacman.d/mirrorlist

# Work through the alternatives
/usr/bin/reflector -p http  --latest 20 -p https -p ftp --sort rate >> /etc/pacman.d/mirrorlist

See also