LinuxCommandLibrary

reflector

Update Pacman mirror list from the reflector project

TLDR

Get all mirrors, sort for download speed and save them

$ sudo reflector --sort [rate] --save [/etc/pacman.d/mirrorlist]
copy

Only get German HTTPS mirrors
$ reflector [[-c|--country]] [Germany] [[-p|--protocol]] [https]
copy

Only get the 10 recently sync'd mirrors
$ reflector [[-l|--latest]] [10]
copy

Use a configuration file to fetch mirrors
$ sudo reflector @[/etc/xdg/reflector/reflector.conf]
copy

Display help
$ reflector [[-h|--help]]
copy

SYNOPSIS

reflector [OPTIONS]

PARAMETERS

-c, --country
    Filters mirrors by specified country. Can be used multiple times for multiple countries. Use --list-countries for a full list.

-f, --fastest
    Outputs only the specified number of fastest mirrors. Requires a speed test.

-l, --latest
    Outputs only the specified number of most recently synchronized mirrors.

-p, --protocol
    Filters mirrors by protocol (e.g., http, https, ftp). Can be used multiple times.

-s, --sort
    Sorts the mirror list by the specified method. Common methods include rate (speed), age (last sync time), score, or country.

--save
    Saves the generated mirrorlist to the specified file. Typically used with /etc/pacman.d/mirrorlist.

--age
    Filters mirrors synchronized within the last specified number of minutes.

--list-countries
    Lists all supported countries from the Arch Linux Mirror Status page.

--threads
    Specifies the number of parallel connections to use for mirror speed testing.

--verbose
    Displays more detailed output during execution, including mirror selection and sorting progress.

DESCRIPTION

reflector is a command-line utility for Arch Linux that retrieves the latest Pacman mirror list from the Arch Linux Mirror Status page, filters the results based on user-specified criteria, and then sorts them according to various metrics such as synchronization time, download speed, or country.

Its primary goal is to help users select fast and up-to-date mirrors, thereby significantly improving the download speeds for package updates and installations. Users can specify parameters like desired countries, preferred protocols (e.g., HTTPS), and the age of the last synchronization. After filtering, reflector can optionally test the speed of the remaining mirrors and output the results, often saved directly to the system's /etc/pacman.d/mirrorlist file, replacing the default or current list.

CAVEATS

reflector requires an active internet connection to query the mirror status page and test mirror speeds. Over-reliance on sorting purely by 'fastest' might occasionally pick a mirror that is fast but unstable or temporarily overloaded. It's recommended to combine speed sorting with other criteria like 'latest' or 'country' for more reliable results.

TYPICAL USAGE

A common way to use reflector is to update the /etc/pacman.d/mirrorlist file, often combined with a service or cron job for regular updates. For example:
sudo reflector --country 'United States' --protocol https --sort rate --save /etc/pacman.d/mirrorlist
This command fetches HTTPS mirrors from the United States, sorts them by speed, and saves the list.

MIRROR SCORE VS. SPEED

The 'score' method sorts mirrors based on a metric provided by the Arch Linux Mirror Status page, which considers factors beyond just raw speed, potentially offering a more balanced selection. 'Rate' (speed) directly measures download speed during the execution of reflector.

HISTORY

reflector was developed specifically for Arch Linux to address the challenge of maintaining an optimal pacman mirror list. Given Arch's rolling release nature and global user base, having a reliable and fast mirror is crucial for efficient system updates. It emerged as a practical solution to automate the process of finding and sorting mirrors, replacing manual editing or less sophisticated scripts.

SEE ALSO

pacman(8), curl(1)

Copied to clipboard