Clearing apt-cacher's cache
I frequently reinstall Ubuntu from scratch, so I’ve set up apt-cacher
on my
fileserver to cache the packages I install - this not only reduces my impact
on the mirrors, but also speeds up my installs.
Occasionally, though, I see strange problems during installs: apt-get install
retrying the download of an apparently-cached package. I haven’t figured out
what’s wrong, and frequently I just want to get the reinstall going again. In
these situations, it seems optimal to just dump the cache and start over; I
haven’t found clear documentation of how to do this, but in case it isn’t
obvious, this works for me (my cache is in /var/cache/apt-cacher
, and I run
it as www-data):
# Stop the service
sudo /etc/init.d/apt-cacher stop
# Move the old cache out of the way, so we can delete it
# in the background (it can take a while)
sudo mv /var/cache/apt-cacher /var/cache/apt-cacher.old
sudo rm -rf /var/cache/apt-cacher.old &
# Make the new cache hierarchy, and set its ownership properly
sudo mkdir -p /var/cache/apt-cacher/{headers,import,packages,private,temp}
sudo chown -R www-data:www-data /var/cache/apt-cacher
# Restart the service
sudo /etc/init.d/apt-cacher start
Update: I found this blog post helpful for manually removing troublesome packages from the cache.