Storing and reusing Ubuntu updates

Suppose you have two computers running the same version of Ubuntu and you have downloaded and installed the updates on one of the computers. Since you are having a rather expensive or maybe, a limited internet connection, you do not wish to download the updates again for the other computer.

Updates downloaded by aptitude are stored in the directory /var/cache/apt/archives. You’ll find the package files in .deb format(Debian software package format). If these updates are copied to the same directory on the other computer, aptitude will automatically recognise those files and use them as necessary while updating. You can copy the files using a flash drive or write them to a CD if you wish to.
You can copy the packages using this command :

sudo cp /var/cache/apt/archives/* /path/to/flash/drive

Now connect the flash drive to the other computer and copy the files to the /var/cache/apt/archives/ directory there.
After this, you need to update your package information and install the updates found.
Run :

sudo apt-get update && sudo apt-get upgrade

All the required updates will be installed from the /var/cache/apt/archives/ directory(if available). You can also install new packages, and they will not be downloaded if they are available locally.

4 Comments

  1. Bruno says:

    Is there a way to disable apt-get cache ? I just realize that I’m quite stupid for doing it manually. After installed I really don’t need it for nothing. Last time I checked I had 3GB used.

    1. Ellimist says:

      There isn’t a way to disable the apt-get cache per se. However, you can run sudo apt-get clean from time to time to clear out the /var/cache/apt/archives/ and /var/cache/apt/archives/partial/ folders.

      1. Bruno says:

        I know; but lately I have been so lazy that I just use the console to compile something or when something crashes. Even updates are installed automatically. From your comment I just realized: why not program cron to do it.

        Besides that, I just realize how this technique can be useful when we need to format that same PC.

        Cheers

        1. Ellimist says:

          Yup, a weekly cron schedule to clean stored updates is reasonable enough.

          Also, as you said, when you have a limited internet connection, reusing stored updates can be a boon after formatting and reinstalling the OS.