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:// 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!

About these ads

16 Responses to “The apt mirror method”

  1. Raphaël Pinson Says:

    Nice feature indeed. Is 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 first, and then down the list there’s In my case, I’m directly on the server so it’s much faster than 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 server”

        Sorry, read : “I’m directly on the 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.


  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.

  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?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: