Stash your cache

Here’s the deal: I reinstall once, sometimes twice or even three times a week. Why? Well, that’s beside the point. Sometimes I break something, but sometimes I just feel like it. Never mind that. What I want to suggest is that, if you’re like me, you can save yourself a little bandwidth and a lot of time downloading if you take the time to copy your apt cache before you erase your drive.

Aptitude (and apt-get and some of those funky little utilities) keep all the packages they downloaded in /var/cache/apt/archives. So the next time you install something chunky, like xorg for example, don’t clean it out with aptitude clean. Instead, copy those files to another location — like a second hard drive or a leftover 128Mb USB drive … you know, the one with the case that snapped so you pried it apart to look at the guts, and it still works but you never use it because it’s somehow not trustworthy without the case.

Then, the next time you install, dump the contents of that USB drive back into /var/cache/apt/archives. Aptitude (or apt-get and some of those funky little utilities) won’t know the difference between those files and the ones that you’re asking it to install, unless there’s a newer version in the repositories, in which case it’s going to download it anyway.

You’re saving yourself something like 40-120Mb — and an hour’s wait — each time you reinstall, depending on what you download and what your connection speeds are. For my own part, I keep a folder of about 140Mb on a modular hard drive, and that serves as my jumpstart archive, so I don’t have to keep downloading and redownloading the same old packages over and over again.

For the terminally uninclined, copy out your cache folder any time you download a big package with this:

cp /var/cache/apt/archives/*.deb /media/usbdisk/

or whatever the name of your destination drive is. To copy it back, use this:

sudo cp /media/usbdisk/*.deb /var/cache/apt/archives/

And remember that you need sudo with the second command, since it’s headed for a directory outside your home.

5 thoughts on “Stash your cache

  1. Isaac Geronimo

    This is a good tip! I’ve been meaning to set up a server to be used as an “I just can’t walk all the way upstairs to my room” machine, as well as print server and, yes, an apt-cache. We’ve got four (sometimes five?) Ubuntu 6.06 PCs running, and I’m thinking that the cache should save a lot of time and bandwidth, especially for the routine system updates.

    The only problem is that I sort of want to update my PC to Ubuntu 7.04, which would make the apt-cache ever so slightly less beneficial. We’ll see.

    Reply
  2. Pingback: Howto: Accelerate Ubuntu upgrades with an ISO « Motho ke motho ka botho

  3. K.Mandla Post author

    Mostly because, last time I checked, APTonCD needed a lot of Gnome dependencies to run, and that’s a turnoff to me. It’s possible that has changed since I last looked.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s