apt-spy is a tool which tests the bandwidth of Debian archive mirrors and generates a file in /etc/apt/sources.list.d with the source list for the fastest mirror.
The most useful options for apt-spy are:
- -d to define which distribution to use. You can use stable, testing or unstable. You can alternatively also use a distribution name e.g. squeeze. You need to set a value to this parameter.
- -a to define the area to check. If not set, apt-spy will check all known mirrors world-wide. Use one of these values: Africa, Asia, Europe, North-America, Oceania or South-America.
To check all mirrors worldwide and generate a sources.list file for stable packages:
# apt-spy -d stable
Of course, if apt-spy is not installed yet, you’ll need to install it first:
# apt-spy -d stable -bash: apt-spy: command not found # apt-get install apt-spy Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: apt-spy 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 33.4 kB of archives. After this operation, 209 kB of additional disk space will be used. Get:1 http://ftp.de.debian.org/debian/ squeeze/main apt-spy amd64 3.1-19 [33.4 kB] Fetched 33.4 kB in 0s (190 kB/s) Selecting previously deselected package apt-spy. (Reading database ... 106526 files and directories currently installed.) Unpacking apt-spy (from .../apt-spy_3.1-19_amd64.deb) ... Processing triggers for man-db ... Setting up apt-spy (3.1-19) ...
Without using the -a parameter, checking the bandwidth of all mirrors will take some time.
Eventually it will find some pretty fast servers:
SERVER: ftp.at.debian.org Benchmarking FTP... Downloaded 7100595 bytes in 2.10 seconds Download speed: 3302.32 kB/sec
Some very slow servers:
SERVER: debian.indika.net.id Benchmarking HTTP... Downloaded 67776 bytes in 20.24 seconds Download speed: 3.27 kB/sec
Some extremely fast servers:
SERVER: ftp.sk.debian.org Benchmarking FTP... Downloaded 7100595 bytes in 1.27 seconds Download speed: 5442.81 kB/sec
And some servers with issues:
... SERVER: mirror.publicns.net Benchmarking FTP... Error: Couldn't resolve host 'mirror.publicns.net' ... SERVER: ftp.linuxforum.net Benchmarking FTP... Error: connect() timed out! ... SERVER: ftp.it.debian.org Benchmarking FTP... Error: couldn't connect to host ... SERVER: debian.uni.edu.ni Benchmarking HTTP... Error: name lookup timed out ... SERVER: ftp.3logic.net Benchmarking FTP... Error: Server denied you to change to the given directory ...
When it is done it will write a sources.list file:
... Writing new sources.list file: /etc/apt/sources.list.d/apt-spy.list # cat /etc/apt/sources.list.d/apt-spy.list # sources.list generated by apt-spy v3.1 # # Generated using: # # apt-spy \ # -d stable # deb ftp://ftp.sk.debian.org/debian/ stable main #contrib non-free deb-src ftp://ftp.sk.debian.org/debian/ stable main #contrib non-free deb http://security.debian.org/ stable/updates main
Next time you run
apt-get update you’ll see that the new mirror is used.