How can I get apt to use a mirror close to me, or choose a faster mirror?

Downloading from the main Ubuntu archive is slow even when it's not release day, how can I get apt-get to automatically use a mirror that is close to me?


Solution 1:

apt-get now supports a 'mirror' method that will automatically select a good mirror based on your location. Putting:

deb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse

on the top in your /etc/apt/sources.list file should be all that is needed to make it automatically pick a mirror for you based on your geographical location.

Lucid (10.04), Maverick (10.10), Natty (11.04), And Oneiric (11.10) users can replace precise with the appropriate name.

Solution 2:

I've always gone with the 'select best server' GUI tool: from Ubuntu Software Center, go to Edit -> Software Sources in the menu. (You can also do this from the Preferences for Synaptic or the Update Manager.)

Under the Ubuntu Software tab there's a drop-down next to "Download from:" If you select "Other..." you'll get a button that says "Select Best Server"; clicking on it gets Ubuntu to run some tests to see what mirror will give the best download speed.

I can't comment on whether this is better or worse than the method you found for yourself. Perhaps someone with some expertise on the issue can comment!


Here are some screenshots for the graphical method, as Jorge suggested:

  1. Open the Ubuntu Software Center, click on Edit in the global menu, and go to 'Software Sources...'

  2. Click on the drop-down menu next to 'Download From' and select 'Other...'

  3. Click on Select Best Server

  4. The best server is highlighted. Click Choose Server and you're done!