Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When doing a aptitude update / apt-get update or using the Update Manager to update sometimes I get to a repository link that takes too long. The percent does not end and it takes quite a while before it ignores it.

How can I lower the time so that if a particular repository takes more than 10 seconds to connect or finish it should ignore it and move the following ones. Here is an image explaining the problem:

enter image description here

It is trying to connect to archive.ubuntu.com but since it is taking too long it just sits there for at least 3 to 5 minutes (Haven't measured the time) and then it shows as ignored and moves to the following. I wish to change that to seconds instead of minutes.

share|improve this question
    
Try using a different mirror. The default ones for each reason often aren't the fastest. For example the default mirror for China would always have me waiting 5-15 minutes to update my repositories. Changed it to a faster one and now it takes about 30 seconds. –  adempewolff May 24 '12 at 5:44
1  
@adempewolff Would you be able/willing to write an answer containing the information in that comment, and also showing (including both a description and an image) how to change the mirror in the Software Sources? –  Eliah Kagan May 24 '12 at 5:47
add comment

3 Answers

up vote 11 down vote accepted

How can I lower the time so that if a particular repository takes more than 10 seconds to connect or finish it should ignore it and move the following ones?

Mirrors are one option, as @adempewolff explained. Let me give you a direct answer though:

Setting apt-get connection timeouts

You can control these timeouts via the following apt.conf options:

  Acquire::http::Timeout "10";
  Acquire::ftp::Timeout "10";
  

Note that this only applies to connection timeouts, NOT "finish time" timeouts, i.e. if it connects within 10 seconds, it will continue to download a 100MB package even if it's at 1 KB/second :)

To implement these options, simply create a conf file in /etc/apt/apt.conf.d; suppose we call it 99timeout.

  • Press Alt+F2, type gksudo gedit /etc/apt/apt.conf.d/99timeout
  • Type/paste the above lines, with your choice of timeout in seconds
  • Save and exit.
  • Now try sudo apt-get update

And the terminal-addict's "find best server" hack!

Expanded and moved as an answer to this more appropriate question


Additional apt-get conf options that you can try to tweak

  • Acquire::Queue-Mode: Queuing mode; Queue-Mode can be one of host or access which determines how APT parallelizes outgoing connections. host means that one connection per target host will be opened, access means that one connection per URI type will be opened.

  • Acquire::Retries: Number of retries to perform. If this is non-zero APT will retry failed files the given number of times.

  • Acquire::http::Dl-Limit: accepts integer values in kilobytes, to throttle download speed and not slow down your browsing/email/etc. when updating. The default value is 0 which deactivates the limit and tries uses as much as possible of the bandwidth. If enabled, it will disable apt-get's parallel downloading feature.

  • Dig through man apt.conf if you think something else might help!

share|improve this answer
    
Is there a way to implement a "finish time" timeout? I know in my case (and I'm guessing in the OP's case as he mentions the percentage taking forever, implying it's already connected) its usually not a matter of the connection timing out, it's just a problem of the connection being painstakingly slow (like 1 kb/s slow). –  adempewolff May 24 '12 at 6:18
    
I wish I could give you +2 for that second part; I've been wondering how to test for the fastest servers from the terminal for a loong time. –  adempewolff May 24 '12 at 6:22
    
Thanks @adempewolff, I actually want to write/modify something like netselect-apt for Ubuntu so it's all in the executable. Re your finish time question, I don't think there is a way at the apt-conf level. But man apt.conf, and see "The Acquire Group", specifically Queue-Mode and Retries which may be helpful. –  izx May 24 '12 at 6:29
    
I accepted but for the "Best server hack" I gave you a +1 on that other answer and this one. It is very smart. –  Luis Alvarado May 24 '12 at 11:18
    
@LuisAlvarado: thank you! :) –  izx May 24 '12 at 13:01
add comment

Often certain repositories loading painfully slow is just a symptom of using a slow mirror. The default mirrors for many regions are not the fastest (I know this is the case in China).

Changing your mirror is really easily done through the Software Sources GUI, you can open this window in two ways:

  1. Open Ubuntu Software Center and click on Software Sources in the Edit menu.

or

  1. Open a terminal (or type alt-F2) and run software-properties-gtk

When this window comes up you'll notice a drop down menu saying Download From: that selects your mirror. Select the Other option from this menu.

softwaresources

In the new window that comes up click the Select Best Server button and this will test and automatically choose the fastest server for your location.

select best server

Hope this helps!

See also:

share|improve this answer
    
Hmmm, I can't get the screenshot to capture the drop-down menu in action. Don't know if I want to ask a question about this or file a bug... –  adempewolff May 24 '12 at 6:01
    
Another possible bug I might file is that the software-properties-gtk program used to come up in the Unity dash when you typed Software Sources, but it no longer does... –  adempewolff May 24 '12 at 6:06
    
Good answer adempewolff. As a first step this would be it. If it does not work then the accepted answer would be the solution. +1 Thanks. –  Luis Alvarado May 24 '12 at 11:21
add comment

apt-fast works like apt-get, but downloads repository updates and packages in parallel. See this tutorial to learn how to use it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.