Reflector for cachyos-mirrorlist

i understand and use cachyos-rate-mirrors to update /etc/pacman.d/cachyos-mirrorlist.

but i prefer the granularity of the reflector command, and use with other arch installs.

if one wanted to completely omit using cachtyos-rate-mirrors and use only reflector in order to have pacman -Syu update using the reflector generated lists, how would one go about that?

pacman.conf has v3, v4 and cachyos all being determined from cachyos-mirrorlist, which seems to only have the mirrors set by cachyos-rate-mirrors command which is run by cachyos-rate-mirrors.timer

whats the work around? RN i have a hybrid update file that uses a modified cachyos-rate-mirrors script that does not rate-mirror the arch repos, only setting mirrors for cachyos-mirrorlist and uses reflector to update the arch repos…works fine, but seems heavy.

 #!/bin/bash

# Colors
bold_cyan="\e[1;36m"
bold_white="\e[1;37m"
reset="\e[0m"

echo -e "${bold_cyan}:: ${bold_white}Starting Rate-mirrors...${reset}"
sudo cachyos-rate-mirrors

# Path to the timestamp file
timestamp_file="$HOME/reflector_timestamp"

# Current time in seconds since epoch
current_time=$(date +%s)

# Check if the file exists
if [[ -f "$timestamp_file" ]]; then
    # Get the last modified time of the timestamp file
    file_mod_time=$(stat -c %Y "$timestamp_file")
    # Compute the age of the file
    file_age=$((current_time - file_mod_time))

    # Check if the file age is less than 12 hours (43200 seconds)
    if [[ $file_age -lt 43200 ]]; then
        echo -e "${bold_cyan}:: ${bold_white}Reflector mirrors < 12hr old...${reset}"
        cat /etc/pacman.d/mirrorlist
        echo -e "${bold_cyan}==> ${bold_white}Starting pacman -Syu...${reset}"
        sudo pacman -Syu --noconfirm
        echo -e "${bold_cyan}[Done]${reset}"
        exit 0
    else
        echo -e "${bold_cyan}:: ${bold_white}Reflector mirrors old...${reset}"
        echo -e "${bold_cyan}==> ${bold_white}Starting Reflector...${reset}"
        sudo reflector --verbose -c CA -c MX -c US --protocol https --sort rate --latest 10 --download-timeout 5 --save /etc/pacman.d/mirrorlist
        echo -e "${bold_cyan}:: ${bold_white}Selected Servers:${reset}"
        cat /etc/pacman.d/mirrorlist
        echo -e "${bold_cyan}==> ${bold_white}Starting pacman -Syu...${reset}"
        sudo pacman -Syu --noconfirm
    fi
else
    echo -e "${bold_cyan}:: ${bold_white}Timestamp file does not exist...${reset}"
    echo -e "${bold_cyan}==> ${bold_white}Starting Reflector...${reset}"
    sudo reflector --verbose -c CA -c MX -c US --protocol https --sort rate --latest 10 --download-timeout 5 --save /etc/pacman.d/mirrorlist
    echo -e "${bold_cyan}:: ${bold_white}Selected Servers:${reset}"
    cat /etc/pacman.d/mirrorlist
    echo -e "${bold_cyan}==> ${bold_white}Starting pacman -Syu...${reset}"
    sudo pacman -Syu --noconfirm
    # Create the timestamp file
    echo -e "${bold_cyan}==> ${bold_white}Saving timestamp file...${reset}"
    touch "$timestamp_file"
    echo -e "${bold_cyan}[Done]${reset}"
    exit 0
fi

# Update the timestamp file with the current time
echo -e "${bold_cyan}==> Updating timestamp file now...${reset}"
touch "$timestamp_file"
echo -e "${bold_cyan}[Done]${reset}"

Hello and welome @destratified **And use this at your own risk!**

To completely replace cachtyos-rate-mirrors with reflector I’ll use this:

Install and configure reflector:

sudo pacman -S reflector

Optionally, install rsync and curl for additional flexibility: sudo pacman -S reflector rsync curl. (I like this for myself)
Set up automatic mirror list updates:

Create or edit the configuration file:

sudo nano /etc/xdg/reflector/reflector.conf

Add your preferred options, such as:

--verbose
--save /etc/pacman.d/mirrorlist
--protocol https
--country 'United States'  # Replace with your country
--sort rate
--latest 20
--number 20

Save and close the file.
Enable the systemd timer:

Enable and start the timer to update the mirror list automatically:

systemctl enable reflector.timer

systemctl start reflector.timer

Verify the timer is active:sudo systemctl enable

systemctl list-timers 

Mine ie:

systemctl list-timers|rg reflector                                                   
Mon 2026-03-02 10:02:56 MST    2 days -                                   - reflector.timer                  reflector.service

Prevent pacman from overwriting your mirror list:

Add NoExtract = /etc/pacman.d/mirrorlist to /etc/pacman.conf to prevent pacman from replacing the file during updates. Mine Reads as follows:

# cachyos repos

NoExtract = /etc/pacman.d/mirrorlist
[cachyos-v3]
Include = /etc/pacman.d/cachyos-v3-mirrorlist

Manually update the mirror list (optional):

sudo reflector --save /etc/pacman.d/mirrorlist 

to update immediately.
Now, reflector will manage your mirror list, and pacman will use the optimized list without interference from cachtyos-rate-mirrors.

so i have essentially been messing around with the reflector systemctl files to do the above…however, i think my question lies specifically with how cachyos-rate-mirrors fills the cachyos-mirrorlist and can that be done without using cachyos-rate-mirrors command. checking the output of cachyos-rate-mirrors, its modifying /etc/pacman.d/cachyos-mirrolist so is there another way to update cachyos-mirrorlist using reflector? or are we bound to cachyos-rate-mirrors to do that for us. i also don’t like that it disables reflector.timer hahaha.
and for the life of me i can’t find where the cachyos-rate-mirrors.hook file is located:

https://github.com/CachyOS/CachyOS-PKGBUILDS/tree/master/cachyos-rate-mirrors

Please break your sentences up a bit, give my Old Eyes an easier read. :wink:

The cachyos-rate-mirrors.hook file is not a standard or officially distributed file in CachyOS.

The cachyos-rate-mirrors tool is a standalone script located at /usr/bin/cachyos-rate-mirrors, and it is typically invoked during system updates via paru, yay or pacman, often integrated into user scripts (like the u() function in .bashrc) rather than being used as a hook file.

cat /usr/bin/cachyos-rate-mirrors                                                    

So we have

  • Main script location: /usr/bin/cachyos-rate-mirrors
    Mirror list files:
  • Arch Linux mirrors: /etc/pacman.d/mirrorlist
  • CachyOS mirrors: /etc/pacman.d/cachyos-mirrorlist

I use it with no issues, I can’t remember the last time I used cachyos-rate-mirrors

I was burned once using it, so reflector it is. :smiley:

sorry about that. cachyos brings with my understanding –and i could be wrong…the cachyos-rate-mirror.service and .timer file @ lib/systemd/system.

so its baked in and will update both /etc/pacman.d/mirrorlist and /etc/pacman.d/cachyos-mirrorlist on boot and every 12hrs

this essentially leaves the user with only having to run sudo pacman -Syu to use the updated mirrorlists with everything happening in the background.

that being said, what if said user “me” doesn’t like rate-mirror and prefers the specificity of the reflector command?

with my script, and or the .service and .timer files for reflector i can update the arch mirrorlist, so what about the cachyos-mirrorlist at /etc/pacman.d/ ?

should i even care if cachyos updates that file? seems like i ought to…but maybe not.

the only way i see to do that is using rate-mirrors cachyos or using cachyos-rate-mirrors. am i wrong about that?

Thank You much better! :+1:

If you value precision, performance, and customization, reflector is indeed a superior and more powerful tool than rankmirrors—and your preference for it is well-founded.

Yes you should care. A better explation might be needed from one of the crew.

I like accurate verbage, not just a guess from me.

when u are using just reflector…are you just using the static cachyos-mirrorlist that was created on the original boot? do you see the cachyos-rate-mirror.timer and .service as active and enabled? it was for me anyways.

the crux of it is, i suppose, if i want to use reflector only it appears that i have to:

  1. use a modified cachyos-rate-mirrors to update only the /etc/pacman.d/cachyos-mirrorlist

  2. disable cachyos-rate-mirrors in pacman.conf with an exclude so it doesn’t overwrite my custom cachyos-rate-mirrors file (which it will on an update or reinstall)

  3. remove the package and opt for a more controlled rate-mirrors approach to update /etc/pacman.d/cachyos-mirrorlist

  4. delete all the above and just use reflector and not worry about an updated cachyos-mirrorlist

i don’t really like option 4), would rather use options 2/3 now that i’m thinking it through…but obviously would prefer a reflector-only option that would address both mirrorlists

That makes 2 of us. :wink:

If your playing around be sure to back-up those Directories and files 1st.

Also The cachyos-mirrorlist file (used for CachyOS-specific repos) is still managed by cachyos-rate-mirrors. If you want to use reflector for CachyOS mirrors, you’ll need to manually generate a custom cachyos-mirrorlist or create a separate script. The reflector tool does not natively support cachyos repos, so you’ll need to handle them separately.

NEXT                             LEFT LAST                              PASSED UNIT                             ACTIVATES                         
Sat 2026-02-28 10:49:05 MST     15min Sat 2026-02-28 09:49:05 MST    44min ago snapper-cleanup.timer            snapper-cleanup.service
Sun 2026-03-01 00:00:00 MST       13h Sat 2026-02-28 06:51:08 MST            - shadow.timer                     shadow.service
Sun 2026-03-01 00:08:57 MST       13h Sat 2026-02-28 07:52:18 MST            - citadel-update-blocklist.timer   citadel-update-blocklist.service
Sun 2026-03-01 00:10:48 MST       13h Sat 2026-02-28 07:14:49 MST            - plocate-updatedb.timer           plocate-updatedb.service
Sun 2026-03-01 00:25:54 MST       13h Sat 2026-02-28 07:48:01 MST            - logrotate.timer                  logrotate.service
Sun 2026-03-01 08:32:03 MST       21h Sat 2026-02-28 10:24:55 MST     8min ago man-db.timer                     man-db.service
Sun 2026-03-01 08:54:02 MST       22h Sat 2026-02-28 08:54:02 MST 1h 39min ago systemd-tmpfiles-clean.timer     systemd-tmpfiles-clean.service
Mon 2026-03-02 01:13:22 MST 1 day 14h Mon 2026-02-23 06:35:37 MST            - fstrim.timer                     fstrim.service
Mon 2026-03-02 01:34:19 MST 1 day 15h -                                      - reflector.timer                  reflector.service
Thu 2026-03-05 15:24:33 MST    5 days Thu 2026-02-12 15:14:21 MST            - archlinux-keyring-wkd-sync.timer archlinux-keyring-wkd-sync.service

10 timers listed.
Pass --all to see loaded but inactive timers, too.

systemctl status cachyos-rate-mirrors.timer                                                                                                                                                                                           ─╯


○ cachyos-rate-mirrors.timer - Automatically refresh arch / cachyos mirror lists
     Loaded: loaded (/usr/lib/systemd/system/cachyos-rate-mirrors.timer; disabled; preset: disabled)
     Active: inactive (dead)
    Trigger: n/a
   Triggers: ● cachyos-rate-mirrors.service

:backhand_index_pointing_up: this is essentially what i’m getting at. :grinning_face: Although maybe it ought to be a feature request? i’m not even sure how to go about that.

but yes, i too was burned by rate-mirrors once upon a time on a garuda distro and haven’t really like rate-mirror for updating since.

with a little bit more digging…rate-mirrors and cachyos-rate-mirrors both code-wise target the mirrorlist and speed-rank it based on (what i assume) is a static list located at

https://raw.githubusercontent.com/CachyOS/CachyOS-PKGBUILDS/master/cachyos-mirrorlist/cachyos-mirrorlist

reflector also points to a url (static https address, but dynamic list) in the code for reflector.py

curious if anyone has forked reflector to sample other urls?? seems like reflector parses a json format, so that might not be helpful.

perhaps just a rate-mirror command tweak saving mirrors at /etc/pacman.d/cachyos-mirrorlist and running it in the same fashion as reflector using .service and .timer will be just fine. probably as simple as it can get without reinventing the wheel

Not that I know of.

I was going to respond here pointing out the difference - as far as I know reflector does not support cachy - but it seems that is already gathered.

While on the other hand rate-mirrors does support Arch and Cachy (and others).

For some more info you might see this (and subsequent replies);

The main problem with rate-mirrors, as far as I can tell, is that it technically does not support the architecture mirrorlists so you would have to manually (or otherwise script, etc) duplicate and slightly modify the outcome for that. This is also mentioned in the linked thread.

It might be automated via something like;

For v3

cp -f /etc/pacman.d/cachyos-mirrorlist /etc/pacman.d/cachyos-v3-mirrorlist
sed -i 's|/$arch/|/$arch_v3/|g' /etc/pacman.d/cachyos-v3-mirrorlist

For v4

cp -f /etc/pacman.d/cachyos-mirrorlist /etc/pacman.d/cachyos-v4-mirrorlist
sed -i 's|/$arch/|/$arch_v4/|g' /etc/pacman.d/cachyos-v4-mirrorlist

For both

cp -f /etc/pacman.d/cachyos-mirrorlist /etc/pacman.d/cachyos-v3-mirrorlist
cp -f /etc/pacman.d/cachyos-mirrorlist /etc/pacman.d/cachyos-v4-mirrorlist
sed -i 's|/$arch/|/$arch_v3/|g' /etc/pacman.d/cachyos-v3-mirrorlist
sed -i 's|/$arch/|/$arch_v4/|g' /etc/pacman.d/cachyos-v4-mirrorlist

yes, for simplicity’s sake cachyos-rate-mirrors does all the above and i am definately overcomplicating things trying to merge reflector arch lists with cachyos…though, generally its working fine. mostly i just like the manual updating and pretty outputs :laughing:

that being said. there is nothing as far as i know that is an alternative to the above, provided as an option with the distro. it seems like rate-mirrors (and cachyos-rate-mirrors) also outputs funny comments to the mirrorlist files by default unless you add in –disable-comments somehow and i like the clean output of reflector.

for now i think im happy with the manual bash script, but linux folk like to tinker and its strange not to find a community solution.

i see the same command lines in /usr/bin/cachyos-rate-mirrors and have thus decided to leave the cachyos-rate-mirror implementation in my script. there’s another tweak i added just below these lines in the executable:

cat /etc/pacman.d/cachyos-mirrorlist | sed '/^\s*#/d;/^$/d' | sudo tee /etc/pacman.d/cachyos-mirrorlist

then blocked automatic updating of cachyos-rate-mirrors in /etc/pacman.conf so as to not loose my changes. if any are interested, i’ve detailed it here:

https://inktheghost.com/blog/arch-cachyos-updater/

I dont think its really over-complicating.
I only use rate-mirrors because I do not like cachyos-rate-mirrors hardcoded defaults.

Personally I just run it when/if needed (like once every few months or if I change geographical regions), with whatever desired options, and then apply it to the mirrorlist files as I like.

I mean .. are you not then that person making that script?

< One post later :sweat_smile: >

In between the first comment and writing we got another comment above

I guess you are. :wink:

Though ..

Instead I would probably copy my fork and name it something else and use that.
Though I guess technically this does not hurt until such time as maybe some breaking changes happen somewhere in the chain.

Of course this kind of thing is generally discouraged.
But its also of course your system.

…

But you are right that we do get a decent amount of questions about some of the oddities of cachyos-rate-mirrors and/or a desire for more control .. and these are some of the same reasons I do not use it.

At one time this was going to mean some extra PRs to update that tool but I think some of the changes are big enough and/or that the use-case slightly differs so instead I began working on an alternative. So I will probably post that somewhere when its something worth sharing.

i am aware of the pacman -Syu –no-confirm and this is mostly left that way as i’ve entered the update command 50 times today while playing with it, that will be removed at some point.

this is kinda exciting. i am by no means an expert tinkerer, but i do like some things some ways and more control is always nice.
i am also just beginning to wrap my head around git and i think i understand what you are getting at with forking, but might need a quick run thru…

FWIW i am not complaining at all, just seems like i am also trying to improve on something that cachyos is also trying to improve on which is a more broad based way to update repos. reflector seems rather specifically written for arch repos, and rate-mirrors work, but with caveats.

thanks for the input as well - in a friendly and constructive forum :+1:

Ah, while forking is used that way and can specifically mean that action in the context of a version control system like git it is also a more general term to mean “copying something and making divergent changes from that point”.

With the comment above

I was using it more generally and in this case was thinking of something like;

sudo cp /usr/bin/cachyos-rate-mirrors /usr/bin/my-cachyos-rate-mirrors

and then making your edits to that new file and using it in your ‘update.sh’, etc.

Which would also bypass the need to ignore the original package and so on.

No worries. At least from me thats the idea and I like to think thats the way we like it. :slight_smile:

ah…gotcha :slight_smile:

For some reference .. do you (or anyone else stopping by) have any particular big wants that you would like to see in the alternative script?

I’m thinking of offering to switch between backends (reflector, rate-mirrors, rankmirrors) where supported and probably country..protocol..max output..

musings on update strategies

cachyos-rate-mirror

i see the functionality of what its accomplishing. what other variables could currently be set? like a –-disable-comments would be useful to cleanup the mirrorlists. also i see cachyos-rate-mirror.timer and .service files, but they don‘t seem to be enabled by default. any other hidden functionalities that could be tapped into, or additional string edits like could be added to the script?

i have not really field verified which mirrors that cachyos-rate-mirrors selects, or if the speeds are comparable, i know that with reflector i can max out my (sad) connection @ 35mb/s and if that’s doable wit cachyos-rate-mirrors, then ditching reflector might be easier for me. i’m still gunna play around with it a bit.

**after 12 hrs testing, i’d say i find them relatively comparable, only noticing that even with county set to US, cachyos-rate-mirrors seems to go farther to return similar results, and more of them.

modifying reflector

digging around in reflector.py its using a url config, albeit json. i am no coder (havent done anything since early 2000s anyways) so i can’t say how hard that would be to reconfigure or modify to pass a url variable, but the cachyos-mirrorlists, whereever they are… https://raw.githubusercontent.com/CachyOS/CachyOS-PKGBUILDS/master/cachyos-mirrorlist/cachyos-mirrorlist from https://github.com/westandskif/rate-mirrors/blob/master/src/targets/cachyos.rs {maybe?}…would need converted to that format, then might be able to be pulled into reflector.py somehow.

rate-mirror

it appears to me that rate-mirror pulls a static list from the above, is that correct? i think i understand how the geoip and KDE servers coming into play in your script - setting the --entry-country variable.

when i use rate-mirror i don’t see the v3 mirrorlists in pacman.d like if i use cachyos-rate-mirror. is that what the sed and backup commands are doing?

here’s the rate-mirror version, so if i go that route, some errors throw till i uncomment lines, below, but then i get a gpg error.

#!/bin/bash

MIRRORS_DEFAULT_DIR=/etc/pacman.d

rate-mirrors --disable-comments cachyos | sudo tee /etc/pacman.d/cachyos-mirrorlist

rate-mirrors --disable-comments arch | sudo tee /etc/pacman.d/mirrorlist

sudo cp -f --backup=simple --suffix="-backup" "${MIRRORS_DEFAULT_DIR}/cachyos-mirrorlist" \
    "${MIRRORS_DEFAULT_DIR}/cachyos-v3-mirrorlist"
sudo cp -f --backup=simple --suffix="-backup" "${MIRRORS_DEFAULT_DIR}/cachyos-mirrorlist" \
    "${MIRRORS_DEFAULT_DIR}/cachyos-v4-mirrorlist"

sudo sed -i 's|/$arch/|/$arch_v3/|g' "${MIRRORS_DEFAULT_DIR}/cachyos-v3-mirrorlist"
sudo sed -i 's|/$arch/|/$arch_v4/|g' "${MIRRORS_DEFAULT_DIR}/cachyos-v4-mirrorlist"

sudo pacman -Syu

sorry to throw so much back at ya, just trying to wrap my head around it in light of providing a better answer…

have you used ghostmirror at all? it kinda replaces reflector, but is more txt file driven. i opened and issue with the developer on their github and the think it might be able to work for cachyos. if it can check mirrors and speeds based on a txt file, maybe could be used in a script with the cachyos-rate-mirror additions to conform to the pacman.conf needs.

ghostmirror issue #25

Its basically a rate-mirrors wrapper and one of the main issues with it, for folks that care, is that there are no configurable options.
rate-mirrors -h would be the comparison for what options might otherwise be available.


Yeah it allows for almost halfway round the world given the options it uses for rate-mirrors.


Yes it sources the list then does its checks from there.


Yup, it does not do that for you. Mentioned above ;


Yes.


You seem to have included ENVVARs that are not defined (MIRRORS_DEFAULT_DIR, etc).
I might guess that is the problem.
See my examples or define those things.


No worries.


No, not familiar.
But maybe it can work? Will look at the issue.