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.

In the interest of conserving bandwidth, I'm considering mounting a VirtualBox host's /var/cache/apt as /var/cache/apt in the guest. Both host and guest are Ubuntu 10.10 32-bit. Would there be any negative consequences to doing this?

I'm aware of the more robust solutions like apt-proxy, but I'd prefer this simpler solution if it's possible in order to spare the host the overhead of running extra services.

share|improve this question

3 Answers 3

up vote 8 down vote accepted

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).

share|improve this answer

Rather than share that folder, will be more "healty" create a LAN repository using APT-CACHER

here 's a tutorial about that software

share|improve this answer
    
A downside of this approach is that VirtualBox will consume more disk space. This should not be a problem if you have a 1TB HDD, but with small SSDs, it is. –  Lekensteyn Mar 9 '11 at 9:59

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.

  1. Installation: apt-get install apt-cacher-ng
  2. 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
  1. Restart Apt-Cacher NG: /etc/init.d/apt-cacher-ng restart
  2. 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"; };

share|improve this answer

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.