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 ..
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/
$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
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.