This handy tutorial will help you to find and select the fastest mirror lists to get update or upgrade or install software’s on your debian systems. As we all know this is very easy to do in GUI mode. We can easily select the region based best nearest mirror list through Synaptic package Manager.
To do that open Synaptic package Manager. Go to Settings -> Repositories. Select “Other” in the “Download From” drop-down box and click on Select Best Mirror.
But what about from command line?
Well, for this Debian has a useful command line tool called “netselect-apt”. Just install the command and run it to find the fastest mirror for your region. It will fetch a fastest mirror lists and you can update your sources.list file with the new mirror list generated by ‘netselect-apt’ to get updates/upgrades effectively.
netselect-apt automatically creates a sources.list file for using with apt for the specified distribution by downloading the list of Debian mirrors using wget and choosing the fastest servers (both US and non- US) using netselect. The output file is written to OUTFILE. If there is a file called mirrors_full in the current directory which lists the Debian mirrors, netselect-apt uses that rather than downloading another copy.
netselect-apt [OPTIONS] [stable|testing|unstable|experimental|release_codename|sid]
Specify which distribution of Debian to use. By default stable is used.
-a, –arch ARCH
Use mirrors containing ARCH. By default the architecture of the current machine is used as reported by dpkg.
While generating OUTFILE include also deb-src lines to use with “apt-get source” to obtain Debian source packages.
-i, –infile INFILE
Use INFILE instead of downloading the mirror list to a temporary file. The file must be in the same format as mirrors_full.
-o, –outfile OUTFILE
Use OUTFILE instead of sources.list.
Include also non-free section while generating OUTFILE.
Use FTP mirrors instead of HTTP and generate OUTFILE accordingly.
The OPTIONS provided are added, verbatim, to netselect when it is run. Here you can provide a (quoted) list of options for net‐select.
-t, –tests hosts
Make a short list with the number of hosts provided and use that list to test for mirror validity. By default 10 hosts are tested.
-c, –country COUNTRY
Only test the sites found under the country COUNTRY (the value can either be an ISO-3166 value or the full name of the language, in English). When this value is set the mirror list or the INFILE will be filtered and only the sites that are listed under the given country will be tested. Note that restricting the search might not give the best results, as the “fastest”
mirror might not even be in the same country as the system the program is running in.
Install ‘netselect-apt’ On Debian
First switch to root user with command:
Then install netselect-apt package with command:
# apt-get install netselect-apt
Find Fastest Debian Mirror
Enter the following command to find fastest debian mirror list.
Append or move the sources.list file contents generated by netselect-apt command to /etc/apt/sources.list file as shown below.
# mv sources.list /etc/apt/sources.list
Now update or upgrade or install software’s in your debian system. You will notice that speed difference.
Find Mirrors Depending Upon Your Distribution Version
I am using Debian 7 ‘Wheezy’. To select mirrors depending upon your distribution version(code name), the command should be:
# netselect-apt wheezy
Suppose if you want to find only the fastest ftp mirrors instead of http, then the command should be:
# netselect-apt -f wheezy
If you want to include non-free repositories, enter the following command:
# netselect-apt -n wheezy
You can also include parameters for stable, non-stable and testing etc. If you didn’t include any parameters, then this command will list the fastest stable http mirror list.
Please note that the speed of this mirrors may vary often, so i suggest you to run this command atleast once in a week and update the sources.list.
For more information about ‘netselect-apt’ command, please refer the man pages.
# man netselect-apt