all repos — website-hugo @ 4c45595047ff6f41fc09723a4a96bd8591ab1eba

My personal blog, built with Hugo!

add reflector.md article
Marco Andronaco andronacomarco@gmail.com
Sun, 29 Jan 2023 13:52:05 +0100
commit

4c45595047ff6f41fc09723a4a96bd8591ab1eba

parent

069c45f18ae01d667ce76b8f735f9111a8dc417d

1 files changed, 78 insertions(+), 0 deletions(-)

jump to
A content/articles/reflector.md

@@ -0,0 +1,78 @@

+--- +title: "Update your mirrors!" +date: 2023-01-29T12:48:40+01:00 +tags: [foss,advice] +--- + +Nah, I'm not talking about [bluetooth mirrors](https://www.bathshack.com/blog/bluetooth-mirrors-everything-you-need-to-know-before-you-buy/). Mirrors are what powers all distros: they're a (de)centralized solution for downloading pre-compiled binaries and scripts for your operating system. + +I use [paru](https://github.com/Morganamilo/paru) to update my ArchLinux system. It's a wrapper for Pacman, so typing `paru` is perfectly equivalent to typing `sudo pacman -Syu`. + +## Suspicion +I like always having the most current version of packages, so I usually update my system several times a day. When, after a day, I ran the update and it reported the system being up to date, I was pretty weirded out. + +Another day passed, and the system was still up to date. It was not a connection problem, I was connecting to my mirrors and they were reporting absolutely zero updates for my system. + +## Problem + +At the third day of stagnation, I was sure something was up. I looked up the [Mirror Status](https://archlinux.org/mirrors/status/) page on ArchLinux's website and saw that loads of mirrors were out of sync. + +I had never touched my mirrorlist before, it was just generated by the [archinstall](https://github.com/archlinux/archinstall) script a few months ago; a lot of Arch-based distros by default ship tools to update your mirrorlist, but I honestly thought I'd never need that. + +Pacman's mirrorlist is located in `/etc/pacman.d/mirrorlist`. You can filter out uncommented lines with this command: + +``` +grep -v "^#" /etc/pacman.d/mirrorlist +``` + +And check the actual status of your mirror(s) on the Mirror Status page linked above. + +## Solution + +This will overwrite your mirrorlist, so you're advised to make a backup before proceeding: + +``` +sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak +``` + +I decided to use [reflector](https://xyne.dev/projects/reflector/) to fix this problem. I didn't want to have to deal with this again, so I enabled the provided systemd timer. + +First, install it. + +``` +sudo pacman -S reflector +``` + +Then, edit `/etc/xdg/reflector/reflector.conf`. I only needed to edit the `--country` parameter and select countries next to the one where I reside; you can list available countries by running `reflector --list-countries`. + +``` +--save /etc/pacman.d/mirrorlist +--protocol https +--country Italy,Switzerland,France,Germany,Austria +--latest 5 +--sort age +``` + +Finally, start the service and check if it worked. +``` +sudo systemctl start reflector.service +cat /etc/pacman.d/mirrorlist +``` + +If everything went smoothly, enable reflector's timer so it runs weekly. +``` +sudo systemctl enable reflector.timer +``` + +Done! + +Now, by default pacman _does_ update its mirrorlist. It creates a file called `mirrorlist.pacnew` and it expects you to pick your favorite mirrors each time its generated. You can disable this (now unneeded) behavior by adding `NoExtract` under "# Misc options" in `/etc/pacman.conf`: + +``` +# Misc options +NoExtract +Color +ILoveCandy +CheckSpace +ParallelDownloads = 3 +```