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?



6 Answers 6


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.

  • n.b. the local directory in question can of course also be a USB drive, such as /media/usbdrive/repository
    – loevborg
    Sep 6, 2010 at 11:25
  • I wrote a quick-and-dirty script that demonstrates a quick-and-dirty local repo: gist.github.com/linuxluser/3af5fd16dde41b82972a
    – Dave
    Oct 24, 2015 at 4:47
  • 1
    I just get dpkg-scanpackages: error: binary directory binary not found Oct 19, 2017 at 0:28

I don't think there is a way to add this as a repository but you can use it to install the packages by copying the contents to your /var/cache/apt/archives. To do this, press alt-f2, enter gksudo nautilus and do the copy. Once you have done, make sure you close the file manager window because it is not a good idea to use the file manager as root except for the tasks that absolutely require it.

To view/install these packages, run System -> Administration -> Synaptic Package Manager, click the 'Origin' button and choose 'Local' from the list.

In the future, you are better off using a program called aptoncd which can be installed from the repositories. It can be used to create a CD image that can be added as a software source. This image can be transported on a usb stick.

The easiest way to add the image as a software source is to burn it to a CD/DVD. You then need to go to System -> Administration -> Software Sources, click 'Other Software' and click 'Add CD-ROM...'.

If you want to use the ISO image as a software source without burning it, the process will be a bit more complicated. You will need to open a terminal Applications -> Accessories -> Terminal and run these commands:

sudo mkdir /aptoncd-mountpoint
sudo mount /media/USB/aptoncd.iso ~/aptoncd-mountpoint -oloop
sudo apt-cdrom -d=/aptoncd-mountpoint add

(source: http://www.debianhelp.org/node/10486)

If you want to download packages on one computer (Linux, Mac or Windows) and install them on an Ubuntu system, you can use keryx.

  • 1
    I don't think this is accurate. There is a file:// URI type. Making an iso image is really much too complicated for this simple task.
    – loevborg
    Sep 6, 2010 at 8:39
  • 2
    It doesn't work. It still tries to mount /dev/sr0.
    – int_ua
    Dec 29, 2011 at 15:15

If you want to use a official CD / USB / ISO image from Ubuntu as repository, you can add this into /etc/apt/sources.list:

deb file:/media/usb xenial main restricted

first, you need to mount your image in /media/usb (for example) and change xenial for your image version.

The server edition only contains main and restricted, while the Desktop version additionally contains universe and multiverse.

My personal case:

After installing Ubuntu (in a server without internet), I forgot to tick the "OpenSSH server" box so the installation finished without it. I tried to dpkg -i openssh....deb but as it requires several dependencies, it was better to do it appropriately. At the end, the selected answer in this page helped me to find out how to use my image as repository and it worked without issues.

This can be useful if you are looking for a way to downgrade a package to an specific version included in an image.


You have backup copies of the package files (that you have downloaded in another computer) in your USB drive. In this situation just create a folder in your home directory, say, ARCHbackUP. Copy all the files from USB to this folder and then follow the codes below:

cd ~
sudo chown -R username:username ARCHbackUP/.
genisoimage -o ARCHbackUP.iso -R -J ~/ARCHbackUP
mv -u ./ARCHbackUP.iso ~/
sudo apt-get clean #cleans the /var/cache/apt/archives directory.
sudo mkdir /mnt/load_iso
sudo mount -o loop ARCHbackUP.iso /mnt/load_iso #mounts the iso archive.
cd /mnt/load_iso #taking you in the mounted directory.
sudo cp -r -n ./. /var/cache/apt/archives
cd ~
sudo umount /mnt/load_iso #unmount the mounted iso archive.
sudo rmdir /mnt/load_iso #deletes the mount point load_iso.

Now all the package files and updates you've downloaded are in the apt-get install search path of your system. Now open your terminal and issue sudo apt-get install package_name to install new packages or sudo apt-get upgrade to update installed packages offline.


You can customize a DVD yourself, refer to http://www.hiroom2.com/2016/08/12/ubuntu-16-04-install-package-from-dvd/ for detail.

ps. I have tried this method on Ubuntu server 16.04 (as it support software RAID), and install ubuntu-desktop with customized DVD.

  • Welcome to AskUbuntu! Please consider expanding your answer, as link-only answers are not of great quality.
    – user308164
    Aug 24, 2016 at 6:46

I was really searching for the same thing for Debian Jessie, but stumbled on this site and found this thread to be more helpful then others. Here is what might work for some ubuntu/ debian-variant fellows.

First, you need to mount your USB in your file manager (probably, Nautilus). Usually it auto-mounts with the default settings though.

As @lepe suggested, i edited the /etc/apt/sources.list and added the following line after some fiddling around:

deb file:/media/your_username/DEBIAN\ 8_1_/dists/jessie jessie main contirb

It worked like a charm. Hope this helps someone although this post is a bit old.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.