A pretty nice (but not much known) piece in apt is the “mirror” method that will automatically select a good mirror based on your location. Putting:
deb mirror://mirrors.ubuntu.com/mirrors.txt natty main restricted universe multiverse
on the top in your sources.list should be all that is needed to make it automatically pick a mirror for you based on your geographical location. With the recent apt upload some issues (mostly in the UI) have been fixed and it should be in good shape now. Feedback for this feature is welcome!
March 22, 2011 at 9:22 am |
Nice feature indeed. Is http://mirrors.ubuntu.com/mirrors.txt dynamically generated depending on the source IP of the client?
March 22, 2011 at 10:29 am |
Yes, its based on geoip and will return a geographical mirror close to you. For me (in germany) it returns a list german mirrors.
March 22, 2011 at 1:52 pm
Nice. I wonder if there could be a way to fine-tune it with networks instead of geographical situation. Some servers might be closer geographically and yet further away on the network.
In my case, I am located in France, so mirrors.txt suggests http://ftp.free.fr first, and then down the list there’s http://ftp.oleane.net. In my case, I’m directly on the oleane.net server so it’s much faster than http://ftp.free.fr. Do you think there could be a way to compute this closeness as more prioritary than the geographical one?
March 22, 2011 at 1:56 pm
“In my case, I’m directly on the oleane.net server”
Sorry, read : “I’m directly on the oleane.net network” instead.
March 22, 2011 at 11:00 am |
Why isn’t your blog on Planet Debian too?
March 22, 2011 at 12:36 pm |
There is no good reason for that. In the past I did not blog much so I never bothered to set it up. But I do it more now so I should add myself there. I just need to lookup how.
March 22, 2011 at 1:16 pm |
Nifty! Might this become default the behaviour in the future? (i.e. the default Ubuntu sources.list pointing to the mirror:// method instead of a round-robin server which is nowhere local to me)
March 22, 2011 at 1:40 pm |
This is EXACTLY what I needed when my local mirrors listed in Lucid went offline. It was a pain to find out where to update the mirror list without breaking the software-sources interface.
This should seriously be considered the default option.
Thanks!
March 23, 2011 at 10:22 am |
Aaron, Marco: I’d definitely be up for making this the default in the Ubuntu installer after a release or so of people using it and it being fairly stable. (I tried it in the past and it wasn’t quite there; I haven’t yet tried Michael’s recent improvements but I’m looking forward to doing so.)
July 1, 2011 at 12:04 am |
It breaks functionality for those expecting to be able to parse the output of apt-get –print-uris in another script. axel, nor wget support mirror://
Not a show stopper, but surely an annoyance.
http://frozen-hell.org/xaerc.d/apt-fast.sh
September 14, 2011 at 8:58 am |
Why isn’t this documented in the sources.list manpage?
Apparently the functionality was already there for hardy…
(also, why can the mirror list not be given as file?)
There doesn’t seem to be *any* documentation for it.
September 14, 2011 at 9:55 am |
Thanks for your feedback. This is indeed undocumented and I’m sorry for that. One reason is that the server part is not quite as good as it could be at this point so the priority for this was not that high. About the file url, that is a excellent idea and I need to look into this.
October 19, 2011 at 6:17 pm |
Michael – I’m just now seeing this, and think it’s great new functionality for apt. I’d like to explore how your mirrorlist text file is generated today, to see if MirrorManager could do likewise for you.
November 21, 2012 at 11:42 am |
[…] After my previous problem trying to update my Ubuntu server running 10.04 I tried to do a release upgrade. Before I was able to do this I had to change the sources.list again, this time I used the mirror schema as recommended here. […]
January 30, 2013 at 1:35 am |
I see that this functionality is in debian’s apt as well, but I cannot find a debian archive that has a mirrors.txt. Is that the only piece that is missing from debian to make this work there? Do you know how that is generated?
February 12, 2013 at 5:55 am |
Debian wants to go a different route, see http://http.debian.net/ for the background. The database from http.debian.net could generate a mirror.txt file too I think.
January 24, 2015 at 8:59 am |
[…] now supports a ‘mirror’ method that will automatically select a good mirror based on your location. […]
March 6, 2015 at 5:10 am |
[…] now supports a ‘mirror’ method that will automatically select a good mirror based on your location. […]
October 13, 2015 at 5:42 pm |
[…] now supports a ‘mirror’ method that will automatically select a good mirror based on your location. […]
May 13, 2017 at 6:20 pm |
Hi, on occasion I see a 404 server error when I arrive at this website. I thought you may wish to know, best wishes
November 24, 2018 at 8:56 pm |
[…] The apt mirror method […]
March 24, 2019 at 9:41 pm |
[…] The apt mirror method […]
March 25, 2019 at 3:39 am |
[…] The apt mirror method […]
December 12, 2019 at 10:21 pm |
[…] The apt mirror method […]
March 20, 2022 at 8:11 am |
[…] could try this method instead, place the following at the top of your /etc/apt/sources.list […]