Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have 2 systems running Debian at home and I am trying to minimize the bandwidth use while upgrading the packages. How can I increase the size limit of the cache, so that I could just copy the packages over LAN? (currently they get removed too quickly)

share|improve this question
1  
What is the output of apt-config dump | grep -i clean? –  enzotib Oct 4 '11 at 16:42
    
Hi @enzotib, I get nothing: grzes:/home/ga# apt-config dump | grep -i clean? grzes:/home/ga# –  Grzenio Oct 5 '11 at 6:57
    
The question mark was not part of the command :) –  enzotib Oct 5 '11 at 6:59
    
Heh :) Without the question mark I get the following: APT::Periodic::AutocleanInterval "0"; –  Grzenio Oct 6 '11 at 9:16
    
It appears that APT::Archives::MinAge (default of 2) should be enough if you tend to do upgrades on both machines at similar times. –  Peter Cordes Feb 4 at 2:44

3 Answers 3

up vote 2 down vote accepted

The size limit is controlled by the apt option APT::Periodic::MaxSize. You can display your current value using the following command:

apt-config dump | grep Periodic

To set the size, edit or create the file /etc/apt/apt.conf.d/99local-archive and any of the following lines:

APT::Periodic::MaxSize "<size_in_MiB>";
APT::Periodic::MaxAge "<days>";
APT::Periodic::MinAge "<days>";

See /etc/cron.daily/apt for comments on available options, and the transition from APT::Archives::*. (Ubuntu 14.04 ships /etc/apt/apt.conf.d/20archive which sets APT::Archives::MaxSize. When they transition to APT::Periodic in that file, it will matter that you put your local changes in a file with a higher number.)

This sets the maximum size of the cache in MiB. If the cache is bigger, cached package files are deleted until the size requirement is met (the biggest packages will be deleted first).

Make sure to do this on all machines that mount the directory.

share|improve this answer
    
It's now APT::Archives::MaxSize, not ...Periodic.... (Ubuntu 14.04, apt 1.0.1ubuntu2.6) There's also ...::MinAge and ...::MaxAge (in days, I guess since the defaults are 2 and 30). I assume MinAge is a grace period for exceeding MaxSize. –  Peter Cordes Feb 4 at 2:32
    
Also note that if either machine does apt-get autoclean, any package that doesn't show up in its list as available will be removed. ` –  Peter Cordes Feb 4 at 2:36
    
Also, Ubuntu ships /etc/apt/apt.conf.d/20archive, (dunno about Debian). Files are processed in order, with later ones able to override earlier ones. (I checked with apt-config dump.) You should put your changed in /etc/apt/apt.conf.d/99local-archive. –  Peter Cordes Feb 4 at 3:58
    
hmm, I wonder if you can set Dir::Cache::archives to an absolute path (like /net/tesla/var/cache/apt/archives/), instead of the default relative path (archives/). Might be easier on a laptop that isn't always kept at home, easier than manually mounting over your local /var/cache/apt/archives/. –  Peter Cordes Feb 4 at 4:05
    
Oops, ignore my first comment. lists.debian.org/deity/2014/03/msg00182.html and /etc/cron.daily/apt indicate that APT::Periodic is the new one, and Archives is the deprecated one. I guess the cron job is the only thing to ever prune the cache, since the size/age stuff is now specific to it. –  Peter Cordes Feb 4 at 5:18

To set the cache size for apt, you need to edit apt.conf. You can get information on how to configure it in man apt.conf. If it is not already present create it in /etc/apt/apt.conf or you may need to edit /etc/apt/apt.conf.d/70debconf file, please refer specific version's documentation.

Debian provides Cache-Limit option in APT Group in apt.conf. You can experiment with it.

man apt.conf says,

Cache-Limit
              APT  uses  a  fixed  size  memory mapped cache file to store the
              'available' information. This sets the size of that cache. 

So you need to put following line in apt.conf.

APT::Cache-Limit "cache_size" Put appropriate cache size in place.

share|improve this answer
1  
Cache-Limit controls the cache in main memory used at runtime, not the disk cache in /var/cache/apt/archives. –  Marco Sep 5 '13 at 10:30
    
Yup, this answer is unfortunately wrong. I guess grzenio accepted it without testing (since it's non-trivial to test.) –  Peter Cordes Feb 4 at 2:42

You should consider using a separate caching proxy for your apt instances. apt-proxy is one tool you could try. Let that do the caching and prune the individual apt archives more aggressively.

share|improve this answer
    
For just 2 machines? Nah just NFS mount /var/cache/apt/archives, esp. now that Marco has identified the right setting to increase the max size. –  Peter Cordes Feb 4 at 2:27

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.