How To Find The Fastest Mirror In Debian And Derivatives

by

Please shareShare on Facebook0Share on Google+3Tweet about this on Twitter17Share on LinkedIn11Share on Reddit1Digg thisShare on StumbleUpon1Share on VKBuffer this page

Having trouble while updating or installing packages in your system? No worries. This brief tutorial will show you how to find the fastest mirror in Debian and it’s derivatives Ubuntu, Linux Mint etc. We can do this either from GUI or command line mode. Pick any one of your preferred method.

Find The Fastest Mirror In Debian And Derivatives

Method 1: Using Synaptic package manager

Finding fastest mirror from the graphical mode is very easy. All you to do is open Synaptic package Manager, go to Settings -> Repositories. From the Ubuntu Software section, Select “Other” in the “Download From” drop-down box, and click on Select Best Mirror.

Software & Updates_002

This will automatically find and select the best mirror for your Debian systems.

_003

After finding your best mirror, select Choose Server.

Choose a Download Server_004

Finally, reload the repositories list. Now, you’ll notice that the downloading speed is significantly increased a bit.

Method 2: Using netselect-apt

A command line tool called “netselect-apt” is available to find the fastest debian mirror. It 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.

Install netselect-apt

Simply, run the following command to install it,

sudo apt-get install netselect-apt

Unfortunately, netselect-apt is not available in Ubuntu 14.04 and recent versions in the default repositories. But, we can download and install the .deb package from here. Go to the download location and install it as shown below.

sudo gdebi netselect_0.3.ds1-25_amd64.deb

If you any dependencies error like below,

Dependency is not satisfiable: netselect (>= 0.3.ds1-17)

Then, download and install the netselect package first. Download netselect from here.

sudo gdebi netselect_0.3.ds1-25_amd64.deb

Finally, install netselect-apt package again.

Usage

Syntax

netselect-apt [OPTIONS] [stable|testing|unstable|experimental|release_codename|sid]

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.

-s, –sources

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.

-n, –nonfree

Include also non-free section while generating OUTFILE.

-f, –ftp

Use FTP mirrors instead of HTTP  and  generate  OUTFILE  accordingly.

-O OPTIONS

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.

Find Fastest Debian Mirror

Enter the following command to find fastest debian mirror list.

sudo netselect-apt

Sample output:

sk@sk: ~_005

At the end, you might have an output like below.

sk@sk: ~_006

This command will automatically select the fastest mirror according to your geographical location and it will save the output in sources.list file in your current directory.

Update Sources.list file

Append or move the sources.list file contents generated by netselect-apt command to /etc/apt/sources.list file as shown below.

First backup the current sources.list file.

sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak

Then, append the new sources.list.

sudo mv sources.list /etc/apt/sources.list

Now update or upgrade or install software’s in your debian system. You will notice the speed difference.

Find Mirrors Depending Upon Your Distribution Version

We will find fastest mirror depending upon our distribution. For example, to find the fastest mirror for Debian 7 Wheezy, run the following command:

sudo netselect-apt wheezy

Suppose if you want to find only the fastest ftp mirrors instead of http, then the command should be:

sudo netselect-apt -f wheezy

If you want to include non-free repositories, enter the following command:

sudo 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 http mirror list for the stable version.

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 accordingly.

For more information about ‘netselect-apt’ command, please refer the man pages.

man netselect-apt
That’s it. Cheers!