How to use an ISO file as offline repository in Debian

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.


If you are not an expert, do not try to mix up different Debian/Ubuntu version ISOs,  i.e. install packages from Debian stretch ISO on a Debian jessie 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/

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




# Debian offline repository mounting or unmounting script.
# By:~

# check for root access
if [ $(id -u) -ne 0 ];then
echo 'run this scripts as root user or use sudo'
exit 1

# 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 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'
echo 'mounting ISO file 1'
mount -o loop /home/$USER/debian-8.0.0-amd64-DVD-1.iso /media/repo_1/

if  $(mountpoint -q /media/repo_2);then
echo 'ISO file already mounted'
echo 'mounting ISO file 2'
mount -o loop /home/$USER/debian-8.0.0-amd64-DVD-2.iso /media/repo_2/

if  $(mountpoint -q /media/repo_3);then
echo 'ISO file already mounted'
echo 'mounting ISO file 3'
mount -o loop /home/$USER/debian-8.0.0-amd64-DVD-3.iso /media/repo_3/


# unmount ISO images

if ! $(mountpoint  -q /media/repo_1/);then
echo 'repo 1 not mounted'
else umount /media/repo_1

if ! $(mountpoint  -q /media/repo_2/);then
echo 'repo 2 not mounted'
else umount /media/repo_2

if ! $(mountpoint  -q /media/repo_3/);then
echo 'repo 3 not mounted'
else umount /media/repo_3

echo 'use sudo mount_CD_repo mount/umount to mount or unmount ISO files'



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.

7 Responses

  1. Koushik says:

    Wonderful !

  2. Chittatosh Pal says:

    Enormous Topic !

  3. 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).

  1. February 26, 2016

    Article Link

  2. March 12, 2016

    […] Article Link […]

Leave a Reply

Your email address will not be published. Required fields are marked *