No internet connection ? still you can install packages on Debian or Ubuntu from the installer CD/DVD ISO file. This trick is very useful in case of downgrading a package, which is no longer available, also saves a lot of valuable data.
Debian installer CD/DVD ISO files suits the best for this purpose, as Debian live CD contains much less packages. Ubuntu, Linux Mint installer ISO files could be used in exactly same way, but they also have few packages.
KNOW THE RISK
If you are not an expert, do not try to mix up different Debian or Ubuntu version ISOs, i.e. install packages from Debian testing ISO on a Debian stable system. This could render your system beyond repair very easily.
So, lest do it ..
Contents
1. Create the folders (mountpoint) to mount the ISO files
sudo mkdir -p /media/repo_1 sudo mkdir -p /media/repo_2 sudo mkdir -p /media/repo_3
2. mount the ISO files
Assuming you have all the three Debian 8.0.0 installer DVD ISO files on your ~/Downloads folder, mount them one by one.
sudo mount -o loop /home/$USER/Downloads/debian-8.0.0-amd64-DVD-1.iso /media/repo_1/ sudo mount -o loop /home/$USER/Downloads/debian-8.0.0-amd64-DVD-2.iso /media/repo_2/ sudo mount -o loop /home/$USER/Downloads/debian-8.0.0-amd64-DVD-3.iso /media/repo_3/
replace $USER
with your user name, or change the path of ISO files to where you Downloaded them .
3. edit the /etc/apt/sources.list file to add the repository
edit the /etc/apt/sources.list file with text editor of your choice, like gedit or nano and add those lines bellow.
deb file:///media/repo_1/ jessie main contrib deb file:///media/repo_2/ jessie main contrib deb file:///media/repo_3/ jessie main contrib
4. now run sudo apt-get update
Done, now you can install packages from this offline repository by running
sudo apt-get install your_package_name # example
Wrapping up everything in a simple shell script
To avoid repeated typing , save the script bellow as mount_ISO_repo , change the path of ISO files and run it when needed like this
sudo ./mount_ISO_repo mount # to mount the repo sudo ./mount_ISO_repo umount # to un mount the repo
The Debian offline repository script
#!/bin/bash # Debian offline repository mounting or unmounting script. # By:~ www.pcsuggest.com # check for root access if [ $(id -u) -ne 0 ];then echo 'run this scripts as root user or use sudo' exit 1 fi # create mount points mkdir -p /media/repo_1 mkdir -p /media/repo_2 mkdir -p /media/repo_3 # mount or unmount case "$1" in mount) # mount Debian DVD ISO images # must change the path of ISO files according to yours if $(mountpoint -q /media/repo_1);then echo 'ISO file already mounted' else echo 'mounting ISO file 1' mount -o loop /home/$USER/debian-8.0.0-amd64-DVD-1.iso /media/repo_1/ fi if $(mountpoint -q /media/repo_2);then echo 'ISO file already mounted' else echo 'mounting ISO file 2' mount -o loop /home/$USER/debian-8.0.0-amd64-DVD-2.iso /media/repo_2/ fi if $(mountpoint -q /media/repo_3);then echo 'ISO file already mounted' else echo 'mounting ISO file 3' mount -o loop /home/$USER/debian-8.0.0-amd64-DVD-3.iso /media/repo_3/ fi ;; umount) # unmount ISO images if ! $(mountpoint -q /media/repo_1/);then echo 'repo 1 not mounted' else umount /media/repo_1 fi if ! $(mountpoint -q /media/repo_2/);then echo 'repo 2 not mounted' else umount /media/repo_2 fi if ! $(mountpoint -q /media/repo_3/);then echo 'repo 3 not mounted' else umount /media/repo_3 fi ;; *) echo 'use sudo mount_CD_repo mount/umount to mount or unmount ISO files' ;; esac
Conclusion
Do you have any question ? just drop a comment, we’d be happy to assist you.
Feel free to share this tutorial with your friends.
mrnobody says
it dont works
i tried but no package can be download by code:apt-get install
Pepe says
NO FUNCIONA LA HUEÁ SHUSHETUMARE
edemko says
hi
thank you much
https://drive.google.com/open?id=17-gdkUg4MVT6BGpadysMOYAqEjCNe3PM
genetix says
beautiful work
user says
works very well, much appreciated.
Yosef Peretz says
me again , did some search and this solved the issue :
deb [trusted=yes] file:///media/repo_1/ stretch main contrib
Thanks
Arnab Satapathi says
Thanks buddy, it's really helpfull, I'll include your suggestion on the article.
torino says
Thank you
I've had some problems with gpg keys ,
I guess this will solve it.
Yosef Peretz says
it doestnt work aptget ended with "the repository is not signed" error
Anon says
Hi, thank you for the nice tutorial.
You are really helping me a lot 😉
How can we include ISOs with different architecture in Debian using this trick?
There are amd64 packages like Wine for example, which relies on i386 packages, after i added "dpkg --add-architecture i386" command and i did the same method as above for the i386 isos, but apt-get update and upgrade doesn't show success.
Can you help me figure this out?
Arnab Satapathi says
That's a really interesting attemp to use ISO files as repo.
Though I've never done that before, but I can say few words about this issue.
First, you should'nt have other http repo enabled on your /etc/apt/sources.list file.
Then modify the 32 bit repo enries a bit like below,
deb [arch=i386] file:///media/repo_1/ jessie main contrib
Then update and try again to install wine.
CN says
hi,
Thank for the guide on setting up offline repository using ISOs files but i got error on finding the packages for KVM like qemu-kvm, libvirt-bin and virt-manager.
Please help.
Arnab Satapathi says
I don't have any debian ISO now to test exactly whats wrong.
Perhaps these packages are not in the ISO file.
Aybars says
Hello,
After all, typing the "sudo apt-get update" command and Terminal window gives the following error:
W: Failed to fetch file:/media/repo_1/dists/jessie/contrib/binary-amd64/Packages File not found
W: Failed to fetch file:/media/repo_2/dists/jessie/contrib/binary-amd64/Packages File not found
W: Failed to fetch file:/media/repo_3/dists/jessie/contrib/binary-amd64/Packages File not found
E: Some index files failed to download. They have been ignored, or old ones used instead.
I've installed Debian 8.7.1 by using netinst. (debian-8.7.1-amd64-netinst.iso)
Now I am trying to update/install other packages in the .iso files: "debian-8.7.1-amd64-CD-1.iso" up to ...CD-8.iso
Regards
Arnab Satapathi says
Are you sure there's no error in your apt sources path ? I mean in the
/media/repo_3/dists/jessie/contrib/
line ? any spelling mistake will make the whole thing unusable.Also use file:/// instead of file:/ , that may cause problems.
Hadi says
It works very well. Just, there is a typo in mount section (you duplicated /media/repo_2. The last one should be /media/repo_3).
Thanks.
Arnab says
Thanks man for pointing that out ! Fixed it.
Chittatosh Pal says
Enormous Topic !
Arnab says
If you have any further question, don't hesitate to leave comments here.
Koushik says
Wonderful !