The apt mirror method

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!

25 Responses to “The apt mirror method”

  1. Raphaël Pinson Says:

    Nice feature indeed. Is http://mirrors.ubuntu.com/mirrors.txt dynamically generated depending on the source IP of the client?

    • mvogt Says:

      Yes, its based on geoip and will return a geographical mirror close to you. For me (in germany) it returns a list german mirrors.

      • Raphaël Pinson Says:

        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?

      • Raphaël Pinson Says:

        “In my case, I’m directly on the oleane.net server”

        Sorry, read : “I’m directly on the oleane.net network” instead.

  2. foo Says:

    Why isn’t your blog on Planet Debian too?

    • mvogt Says:

      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.

  3. Aaron Says:

    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)

  4. Marco Says:

    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!

  5. Colin Watson Says:

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

  6. Donald Clark Says:

    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

  7. mirabilos Says:

    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.

  8. Michael Vogt Says:

    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.

  9. Matt Domsch Says:

    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.

  10. Ubuntu release upgrade | Notes and more Says:

    […] 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. […]

  11. micah Says:

    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?

  12. How do you select the fastest mirror from the command line? - Popular Ubuntu Questions Says:

    […] now supports a ‘mirror’ method that will automatically select a good mirror based on your location. […]

  13. How can I get apt to use a mirror close to me, or choose a faster mirror? | XL-UAT Says:

    […] now supports a ‘mirror’ method that will automatically select a good mirror based on your location. […]

  14. Ubuntu:How can I get apt to use a mirror close to me, or choose a faster mirror? – Ubuntu Linux Questions Says:

    […] now supports a ‘mirror’ method that will automatically select a good mirror based on your location. […]

  15. Mery Says:

    Hi, on occasion I see a 404 server error when I arrive at this website. I thought you may wish to know, best wishes

  16. How do you select the fastest mirror from the command line? – rtrggh Says:

    […] The apt mirror method […]

  17. How do you select the fastest mirror from the command line?How can I search for the fastest update server on the command line?Is it better to use the UK or USA server?How to find fastest mirror from given list?How to choose the fastest mirror in server?Is Says:

    […] The apt mirror method […]

  18. How do you select the fastest mirror from the command line? – frhdtu Says:

    […] The apt mirror method […]

  19. How do you select the fastest mirror from the command line?How can I search for the fastest update server on the command line?Is it better to use the UK or USA server?How to find fastest mirror from given list?Is there any way I can dynamically select a m Says:

    […] The apt mirror method […]

  20. Problems with apt mirrors - Boot Panic Says:

    […] could try this method instead, place the following at the top of your /etc/apt/sources.list […]

Leave a reply to Raphaël Pinson Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.