Change repositories to different mirror - blackMORE Ops

This is a guide on How to change repositories to a different mirror that applies to all Linux distributions. Often you would feel the auto selected mirror via GeoIP is not the fastest one of you’re just paranoid like me who would want to select a mirror from a specific country. This guide would help you to select mirrors manually and control where you download updates from. It might also help you speed up your download if you manage to select a good one.

I am not the original author of this guide, g0tmi1k from Kali Forums wrote it and it is a wonderful guide on how to change repositories to a different mirror.

I am redistributing this to make it more available in search engines as I too failed to find a well written guide on achieve this. I am not even going to try to re-write anything as this Guide is just too good. This was originally written for Kali Linux but any Linux user can find a mirror of their choice, and replace the links to point to their chosen mirror. Other distro users, feel free to leave a comment if you need help.

Original post link How to change the repositories to a different official mirror. Again kudos to gotli1lk for this great guide.

Related posts:

How to add official Kali Linux Repositories?
How to fix Kali Linux apt-get slow update?

So here goes..

How to change repositories to a different mirror

There are several mirrors of the Kali Linux repository server, all of which are spread over the world.
Each time you interact with the repository, by default it will automatically use the mirror that is closest to you based on your geoiplocation (idea being, this will give you the best speed due to less latency).

For whatever reason, you may wish to manually force kali to use a certain/different mirror rather than the one that is nearest you.
Warning: Doing so, if that mirror stops functioning, you will no longer receive updates.

Find your mirror

To start with, you can see what mirror you’re using and other ones near by, by visiting this URL:http://http.kali.org/README.mirrorlist
For example:

…So from the looks of it, in this example ‘ftp.hands.com’ is being used. Lets switch to ‘kali.mirror.garr.it’
(there isn’t a reason or justification for this, just a server that was picked at random).

Make a backup of your sources.list file

Before making any modifications, its highly recommended that you create a backup of any files that will be altered.
This can be done by running:

Change mirror in sources.list file

The default source.list file looks like:

Hint: Kali Linux sources.list Repositories

So we will replace default values with ‘kali.mirror.garr.it’.
From: http – README.mirrorlist we can see the base HTTP URL is: kali.mirror.garr.it/mirrors/kali/

From: security – README.mirrorlist we can see the base security URL is: kali.mirror.garr.it/mirrors/kali-security/

Therefore we can make the switch to ‘kali.mirror.garr.it’ by using the default values as a template, and merging in the information above.

Example command:

The result looks like this:

Test your change

We can then test it out by doing ‘apt-get update’:

…no warnings :)
Done!

Rollback changes

If anything goes wrong at any stage or the server isn’t working, we are able to restore from the backup by doing:

…and everything is back to normal :)

Related posts:

How to add official Kali Linux Repositories?
How to fix Kali Linux apt-get slow update?

Bookmarks/Handy links specific for Kali Linux:

Official Kali Linux Mirrors
Kali Linux sources.list Repositories

What Do You Think on This ? Say Here