How to Set Up a Local Apt Cache for Ubuntu

Setting up a local cache is a smart idea if you’re going to be running a VM server, whether it be KVM, VirtualBox, or any other option really. I assume the same instructions will work with Debian, but I haven’t tried.

First up - install apt-cacher-ng.

apt-get install apt-cacher-ng

Add this to the bottom of your /etc/services:

apt-cacher 3142/tcp apt-cacher 3142/udp

Edit /etc/default/apt-cacher and set AUTOSTART to 1.

See this post in the ubuntu forums for more details.

Restart the service.

/etc/init.d/apt-cacher-ng restart

Bam! You should now have a fully working apt-cacher-ng service, which will make your updates a ton faster. It will also make it easier for you to bootstrap new VMs if you’re using vmbuilder.