Skip navigation

We use to apt-get the packages to install in Debian derivative of Linux. The packages are mostly downloaded from internet based repositories and locally cached at /var/cache/apt/archives directory. In case we reinstall the Linux, we need to download the packages once again to install through apt-get or synaptic GUI tool. To avoid this situation we can backup the *.deb files available in /var/cache/apt/archives path in some other partition than root. After re-installation, we can create a local repository of these packages to avoid downloading again. Another advantage is that this repository can be shared with other computers too. I personally faced this with Ubuntu 5.10 and here is the step by step HOW-TO for the same.

1. Identify the backup partition and directory for downloaded *.deb files (e.g.: /home/swamytk/packages).
2. $ mkdir -p /home/swamytk/packages/archives/dists/main/mysection/binary-i386
3. $ cp /var/cache/apt/archives/*.deb /home/swamytk/packages/archives/dists/main/mysection/
4. $ cd /home/swamytk/packages/archives
5. $ apt-ftparchive packages . > ./dists/main/mysection/binary-i386/Packages
6. $ cd ./dists/main/mysection/binary-i386/
7. $ gzip Packages
8. Re-install the Linux distribution.
9. Add the following entry in /etc/apt/sources.list file.
deb file:/home/swamytk/packages/archives main mysection
10. # apt-get update

That is it. Now you have all your last downloaded files as local repository. Use apt-get or synaptic to go ahead! Enjoy the beauty of apt-get from Debian.



  1. Thanks a bunch! Exactly what I was looking for! Now why hasn’t someone built in a simple local command for apt that would retreive dependancies?

  2. too good! i always wondered if this would be possible!

  3. You are the man!

  4. But this is not good. After this steps you will have not sorted repository. So can you add categorisation to those steps as apt-move?

  5. Thanks a bunch very GOOD TK

  6. Thanks a lot for your valuable contribution which I was eagerly looking for

One Trackback/Pingback

  1. […] is probably something everybody knows, but I’ve been Googling for this answer for over an […]

Leave a Reply

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

You are commenting using your 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

%d bloggers like this: