Sunday, August 27, 2017

Find fastest mirror

This is for arch Linux but the simple technique can be used to sort any other mirrors.

First create a backup of the original /etc/pacman.d/mirrorlist as /etc/pacman.d/mirrorlist.orig

Then create the following simple script:

awk -F'/' '{print $3}' /etc/pacman.d/mirrorlist.orig | grep -v '^$' | while read line;
HEAD $line &>/dev/null && grep -B1 $line /etc/pacman.d/mirrorlist.orig&
done > /etc/pacman.d/mirrorlist

Running this script will create the sorted list of mirrors in /etc/pacman.d/mirrorlist based on how fast the mirror response for the HTTP request.

No comments:

Post a Comment