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.

I have a machine who is using Apt-Cacher NG running on another machine as caching proxy.

When I try to run sudo apt-get update I get the following errors:

W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_main_source_Sources  Hash Sum mismatch
W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_main_binary-amd64_Packages  Hash Sum mismatch
W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_universe_binary-amd64_Packages  Hash Sum mismatch
W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_main_binary-i386_Packages  Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.

The directory /etc/apt/sources.list.d is empty.

To fix that I have already tried the following with no success:

Solution 1:

sudo rm -fr /var/lib/apt/lists
sudo mkdir -p /var/lib/apt/lists/partial
sudo apt-get clean
sudo apt-get autoclean

Solution 2:

sudo apt-get update -o Acquire::http::No-Cache=True

Any suggestion?

share|improve this question
    
I have seen this behaviour sometimes. Running sudo apt-get update several times consecutively helped in this case but I don't know why, never investigated this issue more closely. –  oddfellow Apr 6 '12 at 10:10
1  
This happens also on machines which don't use Apt-Cacher NG. In those cases Solution 1 fixes the problem. –  Krige Apr 19 '12 at 11:57
add comment

6 Answers 6

up vote 5 down vote accepted

I would suggest to switch away from APT-cacher-ng and check out Squid-deb-proxy.

APT-cacher-ng has proven to be very buggy in my experience and tons of bug reports are outstanding. Only recently it has been proposed again to get unblocked in Debian now that some major bugs are squashed. For Ubuntu I've switched to Squid-deb-proxy a long time ago and I don't regret it. It's a great alternative and the best APT-cacher I've come around.

For Squid-deb-proxy, just install the package squid-deb-proxy and add allowed destination domains in a new file in /etc/squid-deb-proxy/mirror-dstdomain.acl.d. As a bonus, clients can auto-discover caching-enabled machines in the local network by having the squid-deb-proxy-client package installed.

share|improve this answer
add comment

You can fix this right now by running:

http://your-cache-server:3142/acng-report.html?abortOnErrors=aOe&byPath=bP&byChecksum=bS&truncNow=tN&incomAsDamaged=iad&purgeNow=pN&doExpire=Start+Scan+and%2For+Expiration&calcSize=cs&asNeeded=an#bottom

This will delete all the broken files in your cache.

To make this permananet, have a look at https://www.unix-ag.uni-kl.de/~bloch/acng/html/maint.html#auto-cleanup

Basically, you can set up the daily cache cleanup cron to do a full checksum match on your entire cache. This will catch all the bad sizes and any other corruption and clean out those files. I edited /etc/cron.daily/apt-cacher-ng and added the following after the comments:

export ACNGREQ="abortOnErrors=aOe&byPath=bP&byChecksum=bS&truncNow=tN&incomAsDamaged=iad&purgeNow=pN&doExpire=Start+Scan+and%2For+Expiration&calcSize=cs&asNeeded=an"

This is equivalent to clicking all the expiry options on the maintenance page except "Skip header checks..."

share|improve this answer
add comment

My upgrades would always almost succeed -- 95% of the files would download through the proxy, leaving maybe the last ~100 files failing with 'hash sum mismatch', and none of the proposed solutions would ever work.

And then, just for grins-and-giggles, I moved 01proxy over to 01proxy.ng, ran aptitude update, then update-manager and selected the distribution-upgrade. It proceeded to download the remaining files from archive.ubuntu.com (~70M rather than ~1G), and the rest of the upgrade went smoothly. After rebooting, I moved 01proxy.ng back to 01proxy, and everything was back to normal.

I've done this twice now, once on the proxy server itself and once on a client, and both succeeded just beautifully after failing (at that 95% mark) when going through the proxy.

share|improve this answer
add comment

I have been fighting VERY frequent (1 in 50 downloads) with "Hash Sum Mismatch" and "Invalid Header" errors using apt-cacher-ng on Ubuntu-Precise 12.04 LTS since the day of upgrading distros. Ubuntu Precise uses apt-cacher-ng version 0.7.2-1, to date there are MANY bug fixes to this software, and the current version: 0.7.6-1 is much more stable.

I have installed the Ubuntu Quanantal version of apt-cacher-ng from packages.ubuntu.com, which is version 0.7.6-1.

I highly recommend grabbing the future/testing version of apt-cacher-ng, and manually installing this newer package.

share|improve this answer
add comment

Suggestion 4

Running sudo apt-get update && sudo apt-get upgrade -y on the Apt-Cacher NG server may fix the problem. You need to do that every time the problem occurs.

Suggestion 5

Sometimes the problem is on the mirror: changing the mirror in /etc/apt/sources.list, both on the server and the clients, may fix this problem.

share|improve this answer
add comment

Suggestion 1

sudo rm /var/lib/apt/lists/*gzip*
sudo rm /var/lib/apt/lists/partial/*gzip*
sudo apt-get update

Suggestion 2

sudo rm -f /var/cache/apt/partial/*
sudo rm -f /var/cache/apt/*.deb
sudo apt-get update

Suggestion 3

sudo touch /etc/apt/apt.conf.d/no-cache
sudo nano /etc/apt/apt.conf.d/no-cache

And paste this in:

Acquire::http {No-Cache=True;};

Now try:

sudo apt-get update
share|improve this answer
    
Thanks but none of the three worked. –  Krige Apr 24 '12 at 16:02
    
Worked like a charm setting no-cache to true! Thanks a million! :) –  mhenrixon May 15 at 11:13
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.