Arch Linux is still my favorite Linux distro for desktop use and once you get it
set up (which may take you a few tries, if it’s your first foray) it tends to be
pretty solid. That is, until you start seeing 404 error messages when you runpacman
, yay
, or whatever your package manager du jour is.
These errors start to show up when you’re using a mirror that had went dark
or is experiencing some intermittent issues.
Like all things Arch, there’s a package that can help you with this situation.
It’s called reflector
and makes it extremely easy to update your mirror list.
It even has a systemd
script that can be setup to run automatically and keep
your mirror list up to date with the fastest servers based on your location.
To get started, you need to install the reflector
package:
sudo pacman -S reflector
ZshOnce installed, you may want to update the configuration to only use mirrors
from your country. First, you’ll want to check the list of available countries:
reflector --list-countries
ZshI’m based in the US, so I want to use the United States
mirrors. Once you know which country or countries you want to use, open the configuration file:
sudo vim /etc/xdg/reflector/reflector.conf
ZshAnd add the line:
--country 'YOUR COUNTRY','OR COUNTRIES'
ZshIf so inclined, you can adjust any of the other configuration options as you see
fit. Aside from adding in my country, I haven’t had any need to update anything
else.
With everything configured, all we need to do is to enable and start thereflector.service
and reflector.timer
services. The reflector.service
will update your mirror list on boot and gets triggered by the reflector.timer
automatically, once per week.
sudo systemctl enable reflector.service reflector.timer
sudo systemctl start reflector.service reflector.timer
ZshIf you’re ever in the position that you need to update your mirror list right
this moment, you can run the reflector.service
to do so:
sudo systemctl start reflector.service
ZshTo check that things have run correctly, you can check out your mirrorlist
file which will have the date/time (in UTC) of the last time the file was generated:
cat /etc/pacman.d/mirrorlist
Zsh