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.

  • Identify the backup partition and directory for downloaded *.deb files (e.g.: /home/<username>/packages).
  • $ mkdir -p /home/<username>/packages/archives/dists/main/myrepo/binary-i386
  • $ cp /var/cache/apt/archives/*.deb /home/<username>/packages/archives/dists/main/myrepo/
  • $ cd /home/<username>/packages/archives
  • $ apt-ftparchive packages . > ./dists/main/myrepo/binary-i386/Packages
  • $ cd ./dists/main/myrepo/binary-i386/
  • $ gzip Packages
  • Re-install the Linux distribution.
  • Add the following entry in /etc/apt/sources.list file.
  • deb file:/home/<username>/packages/archives main myrepo
  • $ sudo 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.