Ubuntu – How to make USB drive as local repository

aptlocalrepositoryrepositorysoftware installation

I copied "archives" folder (/var/cache/apt/archives) from another computer which was fully updated and had some packages that i want. Can someone guide me how to add my USB drive in repository list so that i can install those packages from it?


Best Answer

You should build a repository in a local directory and point a file: URI entry to your APT sources (see URI SPECIFICATION in man sources.list):

deb file:/home/user/repository

To make apt work, you need to create a list of packages (Packages.gz) for APT to consume. This is explained in detail here. For your case, it should be quite easy. I refer you to the "Trivial Repositories" section of the manual. It should be as easy as changing to, say, /home/user/repository and running

dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz

Then after a apt-get update, the packages should become available. Perhaps if you want to make this source take precedence over others, you need to assign it a higher priority; for that see the APT manual pages.

Related Question