Manage your Arch Linux mirrors with 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.
Instalation
- Install reflector
1yay -S reflector
- Create the systemd service
1sudo vi /etc/systemd/system/reflector.service
1[Unit]
2Description=Pacman mirrorlist update
3Wants=network-online.target
4After=network-online.target nss-lookup.target
5
6[Service]
7Type=oneshot
8ExecStart=/usr/bin/reflector --verbose --protocol https --country 'Portugal' --latest 30 --number 20 --sort rate --save /etc/pacman.d/mirrorlist
9
10[Install]
11WantedBy=multi-user.target
1sudo systemctl daemon-reload
2sudo systemctl start reflector.service
3sudo 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:
1sudo systemctl start reflector.service
Or every time the pacman-mirrorlist package is updated by creating a hook:
1sudo mkdir -p /etc/pacman.d/hooks/
2sudo vi /etc/pacman.d/hooks/mirrorupgrade.hook
1[Trigger]
2Operation = Upgrade
3Type = Package
4Target = pacman-mirrorlist
5
6[Action]
7Description = Updating pacman-mirrorlist with reflector and removing pacnew...
8When = PostTransaction
9Depends = reflector
10Exec = /bin/sh -c "reflector --verbose --protocol https --country 'Portugal' --latest 30 --number 20 --s
11ort rate --save /etc/pacman.d/mirrorlist; rm -f /etc/pacman.d/mirrorlist.pacnew"
Need more help?
Check the reflector help:
1reflector --help
Or check the Arch Wiki.