Honhar Engineer

Honhar Engineer
Thanks for visiting,stay connected for more updates !

Saturday, April 12, 2014

How to change repositories to a different mirror?

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:

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 geoip location (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:
 Found 1 mirror which handle this country (GB):

 http://ftp.hands.com/kali/README (gb, prio 100)
 Found 5 mirrors in other countries, but same continent (EU):

 http://ftp.free.fr/pub/kali/README (fr, prio 200)
 http://mirror.pcextreme.nl/kali/README (nl, prio 200)
 http://ftp.halifax.rwth-aachen.de/kali/README (de, prio 100)
 http://kali.mirror.garr.it/mirrors/kali/README (it, prio 100)
 http://ftp.cc.uoc.gr/mirrors/linux/kali/kali/README (gr, prio 100)
…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:
root@kali ~$ cp -f /etc/apt/sources.list{,.bkup}

Change mirror in sources.list file

The default source.list file looks like:
 root@kali~$ cat /etc/apt/sources.list | grep -v '^#' | uniq

 deb http://http.kali.org/kali kali main non-free contrib
 deb-src http://http.kali.org/kali kali main non-free contrib

 deb http://security.kali.org/kali-security kali/updates main contrib non-free
 root@kali~$
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/
 Before (default/original)
   deb http://http.kali.org/kali kali main non-free contrib
   deb-src http://http.kali.org/kali kali main non-free contrib

 After (static mirror/manually altering)
   deb http://kali.mirror.garr.it/mirrors/kali/  kali main non-free contrib
   deb-src http://kali.mirror.garr.it/mirrors/kali/ kali main non-free contrib
From: security – README.mirrorlist we can see the base security URL is: kali.mirror.garr.it/mirrors/kali-security/
 Before (default/original)
   deb http://security.kali.org/kali-security kali/updates main contrib non-free

 After (static mirror/manually altering)
   deb http://kali.mirror.garr.it/mirrors/kali-security/ kali main non-free contrib
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:

 echo '# kali.mirror.garr.it
 deb http://kali.mirror.garr.it/mirrors/kali/ kali main non-free contrib
 deb-src http://kali.mirror.garr.it/mirrors/kali/ kali main non-free contrib

 deb http://kali.mirror.garr.it/mirrors/kali-security/ kali main non-free contrib' > 
/etc/apt/sources.list

The result looks like this:

 root@kali:~# echo '# kali.mirror.garr.it
 > deb http://kali.mirror.garr.it/mirrors/kali/ kali main non-free contrib
 > deb-src http://kali.mirror.garr.it/mirrors/kali/ kali main non-free contrib
 >
 > deb http://kali.mirror.garr.it/mirrors/kali-security/ kali main non-free contrib' >
 /etc/apt/sources.list
 root@kali:~# cat /etc/apt/sources.list
 # kali.mirror.garr.it
 deb http://kali.mirror.garr.it/mirrors/kali/ kali main non-free contrib
 deb-src http://kali.mirror.garr.it/mirrors/kali/ kali main non-free contrib

 deb http://kali.mirror.garr.it/mirrors/kali-security/ kali main non-free contrib
 root@kali:~#

Test your change

We can then test it out by doing ‘apt-get update’:
 root@kali:~# apt-get update
 Get:1 http://kali.mirror.garr.it kali Release.gpg [836 B]
 Get:2 http://kali.mirror.garr.it kali Release.gpg [836 B]
 Get:3 http://kali.mirror.garr.it kali Release [21.1 kB]
 Get:4 http://kali.mirror.garr.it kali Release [8,791 B]
 Get:5 http://kali.mirror.garr.it kali/main Sources [7,531 kB]
 Get:6 http://kali.mirror.garr.it kali/non-free Sources [117 kB]
 Get:7 http://kali.mirror.garr.it kali/contrib Sources [55.5 kB]
 Get:8 http://kali.mirror.garr.it kali/main i386 Packages [8,450 kB]
 Get:9 http://kali.mirror.garr.it kali/non-free i386 Packages [115 kB]
 Get:10 http://kali.mirror.garr.it kali/contrib i386 Packages [55.2 kB]
 Get:11 http://kali.mirror.garr.it kali/main i386 Packages [284 kB]
 Get:12 http://kali.mirror.garr.it kali/non-free i386 Packages [20 B]
 Get:13 http://kali.mirror.garr.it kali/contrib i386 Packages [616 B]
 Ign http://kali.mirror.garr.it kali/contrib Translation-en_GB
 Ign http://kali.mirror.garr.it kali/contrib Translation-en
 Ign http://kali.mirror.garr.it kali/main Translation-en_GB
 Ign http://kali.mirror.garr.it kali/main Translation-en
 Ign http://kali.mirror.garr.it kali/non-free Translation-en_GB
 Ign http://kali.mirror.garr.it kali/non-free Translation-en
 Ign http://kali.mirror.garr.it kali/contrib Translation-en_GB
 Ign http://kali.mirror.garr.it kali/contrib Translation-en
 Ign http://kali.mirror.garr.it kali/main Translation-en_GB
 Ign http://kali.mirror.garr.it kali/main Translation-en
 Ign http://kali.mirror.garr.it kali/non-free Translation-en_GB
 Ign http://kali.mirror.garr.it kali/non-free Translation-en
 Fetched 16.6 MB in 11s (1,388 kB/s)
 Reading package lists... Done
 root@kali:~#
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:
 root@kali:~# cp -f /etc/apt/sources.list{.bkup,}
 root@kali:~# apt-get update
 Get:1 http://security.kali.org kali/updates Release.gpg [836 B]
 Get:2 http://http.kali.org kali Release.gpg [836 B]
 Get:3 http://security.kali.org kali/updates Release [11.0 kB]
 Get:4 http://http.kali.org kali Release [21.1 kB]
 Get:5 http://security.kali.org kali/updates/main i386 Packages [143 kB]
 Get:6 http://http.kali.org kali/main Sources [7,531 kB]
 Ign http://security.kali.org kali/updates/contrib Translation-en_GB
 Ign http://security.kali.org kali/updates/contrib Translation-en
 Ign http://security.kali.org kali/updates/main Translation-en_GB
 Ign http://security.kali.org kali/updates/main Translation-en
 Ign http://security.kali.org kali/updates/non-free Translation-en_GB
 Ign http://security.kali.org kali/updates/non-free Translation-en
 Ign http://http.kali.org kali/contrib Translation-en_GB
 Ign http://http.kali.org kali/contrib Translation-en
 Ign http://http.kali.org kali/main Translation-en_GB
 Ign http://http.kali.org kali/main Translation-en
 Ign http://http.kali.org kali/non-free Translation-en_GB
 Ign http://http.kali.org kali/non-free Translation-en
 Get:7 http://http.kali.org kali/non-free Sources [117 kB]
 Get:8 http://security.kali.org kali/updates/contrib i386 Packages [20 B]
 Get:9 http://http.kali.org kali/contrib Sources [55.5 kB]
 Get:10 http://security.kali.org kali/updates/non-free i386 Packages [20 B]
 Get:11 http://http.kali.org kali/main i386 Packages [8,450 kB]
 Get:12 http://http.kali.org kali/non-free i386 Packages [115 kB]
 Get:13 http://http.kali.org kali/contrib i386 Packages [55.2 kB]
 Fetched 16.5 MB in 18s (870 kB/s)
 Reading package lists... Done
 root@kali:~#
and everything is back to normal :)

Related posts:

Bookmarks/Handy links specific for Kali Linux:


Thanks for reading.
Do you Like this story..?

Get Free Email Updates Daily!

Follow us!

No comments:

Post a Comment