Find The Fastest Arch Linux Reposity Mirror(s) With Rankmirrors

By | 03/12/2009

I setup a new Desktop at work today and I thought I’d try out Arch again.  I’ve had it running on my work Laptop for a few months now, but there were some things I wanted to figure out and learn, “The Arch Way”.  One of the little tips that I found in my continued reading and setting up was the use of the rankmirrors tool.  Rankmirrors will find and configure your system to use the fastest repository mirrors for your connection.

Getting Started

Let’s assume you’re on a fresh installation.  If not, the steps are really the same, you just likely don’t have to worry about resolving the dependencies.  So, on that note, the only dependency for the tool is python.  If you don’t have python installed (which is likely only the case if you’re on a fresh installation), you’ll need to install it:

pacman -S python

Running Rankmirrors

Rankmirrors will read a copy of the mirrorlist file and output an updated, ranked mirrorlist file.  To do this cleanly, in the fewest steps, well move the original file which is what we’ll read from and then output to the file we’ll end up using.

mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig
rankmirrors -n 3 /etc/pacman.d/mirrorlist.orig > /etc/pacman.d/mirrorlist

This will take a little time to run through the list and compare the results, but when it is finished you’ll have a mirrorlist file that is optimized for your connection.  You’ll also notice that I used the “-n3” option, which tells it to output the three fastest repository mirrors.  You can change this number based on your needs.

Also, anytime you update or change your repository mirror you’ll want to make sure pacman is updated accordingly.  Run the following command anytime you make changes to your mirror:

pacman -Syy

3 thoughts on “Find The Fastest Arch Linux Reposity Mirror(s) With Rankmirrors

  1. Jaap Visser

    Good suggestion but there is a little mistake in the example.

    a) The command is not “rankmirror” but “rankmirrors”
    b) After moving “mirrorlist” to “mirrorlist.orig” you have to create a new “mirrorlist” file before you can “>” to it.

    Below worked for me:

    mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig

    touch /etc/pacman.d/mirrorlist

    rankmirrors -n3 /etc/pacman.d/mirrorlist.orig > /etc/pacman.d/mirrorlist

    Reply
    1. admin Post author

      @Jaap – thanks for catching my mistake. I have updated the post to read ‘rankmirrors’ where applicable.

      Also, the touch command shouldn’t be needed, as the redirection using > will create the file if it doesn’t exist.

      Thanks again for your feedback!

      Reply
  2. a b

    just a quick remark:

    for me it was important to put a whitespace between ‘-n 3’.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *