Would there be any negative side-effects of sharing /var/cache/apt/ between two systems?
Solution 1:
I believe that /var/cache/apt/{,src}pkgcache.bin
contains the current installed packages.
Instead of sharing /var/cache/apt/
, share the /var/cache/apt/archives/
directory, which contains independent files. You have to do some tweaking, because /var/cache/apt/archives
is owned and writable only by root. One option would be setting the group of /var/cache/apt/archives
to apt-cache-writer
and adding the setgid bit to the directory. Add yourself to the apt-cache-writer
group and set the umask
to something like 0002
or 0007
instead of 0022
.
Note that sudo apt-get clean
clears this directory (/var/cache/apt/archives
).
Solution 2:
Rather than share that folder, will be more "healty" create a LAN repository using APT-CACHER
here 's a tutorial about that software
Solution 3:
Your best solution is to use Apt-Cacher-NG on the host machine. You don't need to worry about dedicating a networked computer for aptcacher because it runs as a simple program with a simple instalation/configuration. The only think to watch out for is the amount of disk space you have fee but I have been using this setup for quite a while so far and it hasn't been a problem.
It may seem odd but you can also use apt-cacher for the machine that apt-cacher is installed on. This means that if your VM updates before your host it will populate the cache and the Host will be able to get the package from the cache.
You will also be able to see statistics of how much is being cached and what the hit rate is by putting the url: "http://your-apt-cacher-ng-server:3142" in your browser (see below).
A good simple explanation of how to configure the apt-cacher can be found here: http://acidborg.wordpress.com/2010/06/24/how-to-install-and-configure-apt-cacher-ng-on-ubuntu-server-10-04/ which I will paste below for completeness.
- Installation:
apt-get install apt-cacher-ng
- Configuration: Edit
/etc/apt-cacher-ng/acng.conf
with the following content:
CacheDir: /var/cache/apt-cacher-ng LogDir: /var/log/apt-cacher-ng Port:3142 BindAddress: 0.0.0.0 Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu PidFile: /var/run/apt-cacher-ng/pid ExTreshold: 4
- Restart Apt-Cacher NG:
/etc/init.d/apt-cacher-ng restart
-
Create on the rest of the Debian/Ubuntu machines on the network the file
/etc/apt/apt.conf.d/02proxy
with the following content:Acquire::http { Proxy "http://your-apt-cacher-ng-server:3142"; };