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 --country [Germany] --protocol [https]
copy

Only get the 10 recently sync'd mirrors
$ reflector --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

--country
    Filter mirrors by country. Use comma-separated country codes (e.g., US,CA,GB).

--age
    Filter mirrors based on how recently they were last synchronized (in hours).

--protocol
    Filter mirrors by protocol (HTTP or HTTPS).

--number
    Limit the number of mirrors to output.

--sort
    Sort mirrors by 'rate', 'age', 'delay', 'score', or 'name'.

--save
    Save the mirrorlist to the specified file (usually /etc/pacman.d/mirrorlist).

--list-countries
    List available country codes.

--verbose
    Enable verbose output.

--help
    Display help message.

--version
    Display version information.

--url
    Specify a URL to retrieve the mirror list from instead of the default Arch Linux mirror status page.

--threads
    Specify the number of threads to use for downloading mirror data.

--fastest
    Return the fastest mirrors based on download time.

DESCRIPTION

reflector is a command-line utility used to retrieve a list of the most up-to-date mirrors for the Arch Linux pacman package manager. It filters and sorts these mirrors based on criteria like download speed and freshness (last synchronization time). This helps users improve the reliability and speed of package downloads.

reflector allows users to customize the selection process based on country, protocol (HTTP/HTTPS), and mirror status. It can also automatically generate a pacman mirrorlist file (/etc/pacman.d/mirrorlist) containing the sorted and filtered mirrors. By using reflector, users can ensure they are using the best available mirrors for their location and network conditions, which leads to faster and more reliable package updates and installations. It is a commonly used tool in the Arch Linux ecosystem for optimizing the package management experience.

CAVEATS

Running reflector requires root privileges to modify /etc/pacman.d/mirrorlist. Incorrectly configured options can result in a broken pacman setup.

USAGE EXAMPLES

  • Update mirrorlist with the 10 fastest mirrors: reflector --fastest 10 --save /etc/pacman.d/mirrorlist
  • Use only mirrors from the US and Canada: reflector --country US,CA --save /etc/pacman.d/mirrorlist
  • Find mirrors synced within the last 12 hours sorted by rate: reflector --age 12 --sort rate --save /etc/pacman.d/mirrorlist

HISTORY

reflector was created to simplify and automate the process of managing pacman mirrorlists. It evolved from manual mirror selection to an automated tool that dynamically adjusts the mirrorlist based on network conditions and mirror availability. It gained popularity within the Arch Linux community for its effectiveness and ease of use.

SEE ALSO

Copied to clipboard