Zed Lopez

Fastest Ubuntu Mirror for You

I recently learned about netselect-apt, a Debian package to find the fastest Debian mirror. Ubuntu Hardy includes it, but it’s worse than useless – it’s still hard-coded to work with Debian. But it’s easy enough to reproduce its essential functionality.

sudo apt-get install netselect
wget –no-check-certificate -O mirrors https://launchpad.net/ubuntu/+archivemirrors
sudo netselect -v -s 5 $(perl -F’”’ -ane ‘print “$F[1] ” if (/United States/ .. /highlighted/) && /http/’ mirrors)

That gives the top 5 (from fastest to slowest) in the US using http. It should be reasonably clear how to adjust the number returned, the country, or the protocol (which could be ‘ftp’ or ‘rsync’.) It erroneously considers canonical.com a mirror in Viet Nam (it fails to find the end correctly for the last country in the list), but there’s only one mirror in Viet Nam, and this is a quick hack, so I can live with that.