I know I can't install previous version without a local copy of the archive of needed version. But today I found out something surprising: I was sure that all previous archives are stored in cache. But after I upgraded firefox from v28 to v29 and checked available versions to install, result is unexpected for me:

$ apt-cache madison firefox
firefox | 29.0+build1-0ubuntu0.12.04.2 | http://archive.ubuntu.com/ubuntu/ precise-updates/main i386 Packages
firefox | 29.0+build1-0ubuntu0.12.04.2 | http://security.ubuntu.com/ubuntu/ precise-security/main i386 Packages
firefox | 11.0+build1-0ubuntu4 | http://archive.ubuntu.com/ubuntu/ precise/main i386 Packages

There is no version 28. I checked /var/cache/apt/archives, and there is actually no archive of version 28. That is sad that it is removed.

How can I prevent it from removing old archives?


The Apt cache is managed by a daily cron job. To modify the default settings, open (as root) /etc/apt/apt.conf.d/20archive:

APT::Archives::MaxAge "30";
APT::Archives::MinAge "2";
APT::Archives::MaxSize "500";

To disable the automatic removal, set the three values to 0.

See the top of of /etc/cron.daily/apt for a brief documentation of these options.

| improve this answer | |
  • Yeah thanks: I have another computer without this file /etc/apt/apt.conf.d/20archive (no idea why btw, OS is the same and up-to-date as well), I just checked apt cache archive on it, and there are many old versions of the packages. Thanks. – Dmitry Frank May 12 '14 at 19:21

From man apt-get

Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.

Check what the current value is with apt-config dump|grep Clean

In /etc/apt/apt.conf add:

APT::Clean-Installed "false";

Also see What is difference between the options “autoclean”, “autoremove” and “clean”?

| improve this answer | |
  • But I haven't executed autoclean, I just upgraded the package. In manual, I can't find that autoclean is executed automatically after upgrading the package. To be honest I can't check it now, because now all the packages are up-to date, and there is nothing to upgrade, so I have to wait until something new will come – Dmitry Frank May 12 '14 at 12:39
  • Do you run unattended-upgrades or any other cron job that would call autoclean? – bain May 12 '14 at 12:58
  • No. I had non-zero values in the etc/apt/apt.conf.d/20archive as @SylvainPineau mentioned, but they should not affect the package right away after upgrading – Dmitry Frank May 12 '14 at 13:02
  • Anyway, thanks for the information and for trying to help. – Dmitry Frank May 12 '14 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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