53

I have all images of Debian, Ubuntu and Ubuntustudio as .iso. How can I use them as repository to install my desired packages with sudo apt-get install package-name?

I easily mount the .iso file with Archive Mounter, but when adding CD-ROM in Software Sources it says Please Insert CD-ROM.

How should I do this without burning them to disk?

0

11 Answers 11

18

This question has already been answered as part of an answer to a different question: How to make USB drive as local repository

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)

7
  • 1
    But this method is not working anymore. I tried this with xubuntu-11.10-alternate-iso, and it says Failed to mount '/dev/sr0' to '/media/apt/' and Unable to locate any package files, perhaps this is not a Debian Disc or the wrong architecture? .
    – Anwar
    May 11, 2012 at 8:26
  • 2
    I think the second command is sudo mount /media/USB/aptoncd.iso /aptoncd-mountpoint -oloop without ~ before /aptoncd-mountpoint
    – Anwar
    May 11, 2012 at 8:39
  • Still not working!
    – BigSack
    Aug 11, 2012 at 15:15
  • 4
    -o loop not -oloop
    – 3pic
    Aug 6, 2015 at 9:20
  • 1
    I added the trusted=yes but still most of the package checksums are bad. any idea?
    – JPT
    Aug 4, 2023 at 17:38
14

Try this

mkdir /media/mountpoint  
mount -t iso9660 -o loop /pathtoiso.iso /media/mountpoint  

then add deb file:///media/mountpoint distro main contrib to /etc/sources.list with text editor and not with some GUI tool, then update from package manager.

3
  • 1
    This is an accepted answer
    – Sarit
    Jan 6, 2018 at 10:20
  • I used this answer but with sudo for the mount commands, then temporarily added that to my ~/.bashrc while I set up this system.
    – Adam Prall
    Feb 25, 2020 at 4:18
  • path of the file to edit actually is /etc/apt/sources.list.
    – kyklops
    Oct 27, 2023 at 15:22
6
sudo mount  ~/Desktop/ubuntu-12.04.3-desktop-i386.iso /media/apt
sudo apt-cdrom --no-mount -d=/media/apt add

This works.

1
  • 5
    This is not working unless we add -m option to apt-cdrom to prevent auto unmounting. If not, the virtual "cd-rom" will be unmounted even if it's mounted beforehand. So the complete syntax is: sudo mount /iso/path /mount/point. And then, sudo apt-cdrom -d=/mount/point add -m
    – WesternGun
    Sep 12, 2016 at 13:49
5

The above steps didn't worked for me. Anyways I happened to work it out with the help of debian user list and it worked.

Here are the steps.

  1. Assume you have the iso file in /home/iso-files/ folder. I had the debian-7.1.0-amd64-DVD-1.iso in /home/iso-files folder

  2. Make a new folder in /media

    mkdir /media/dvd1-mountpoint
    

    you will have to run the above command as root

  3. Run the following command as root

    mount ~/iso-files/debian-7.1.0-amd64-DVD-1.iso /media/dvd1-mountpoint -o loop 
    
  4. Add an entry to /etc/fstab as follows

    ~/iso-files/debian-7.1.0-amd64-DVD-1.iso /media/dvd1-mountpoint iso9660 loop,ro,user,noauto 0       0
    
  5. Make an entry in your /etc/apt/sources.list as follows

    deb file:/media/dvd1-mountpoint/ wheezy main contrib
    
  6. Comment out everything else in /etc/apt/sources.list by adding a # at the start of every entry. only the above line should be uncommented.

  7. Run the following command as root

    apt-get update
    
  8. Install any package name and now it should work.

    apt-get install somePackage
    
  9. You can check if your entry in fstab is correct or not by unmounting the dvd and then directly mounting the mountpoint

    umount /media/dvd1-mountpoint
    mount /meida/dvd1-mountpoint
    
  10. If you plan to automount the dvd at start up you should remove user,noauto from entry in /etc/fstab

The above steps are working just perfectly for me. It should work for you also! I know I am pretty late to answer you, but anyways!

2

I found the answer here: http://ubuntuguide.net/4-ways-to-upgrade-to-ubuntu-11-04-natty-narwhalonlineoffline (number 4).

Essentially, what it suggests is mounting the ISO as a CDROM. This probably fools the system into believing the ISO image is a real CD.

sudo mount -t iso9660 -o loop PATH/TO/ISO /cdrom

(I'm using this method to upgrade from 11.10 to 12.04 Alpha2, because it won't fit on a CD and for some reason my system isn't happy with USB drives.)

1

I method described by dv3500ea does not working now. (I think it worked in past). It displays a message like:

    W: Failed to mount '/dev/sr0' to '/media/apt/'
    E: Unable to locate any package files, perhaps this is not a Debian Disc or the wrong architecture?

I fount this workaround useful:

After doing dv3500ea's method's first two steps, (I write this again for user's convenience)

sudo mkdir /aptoncd-mountpoint
sudo mount /media/USB/aptoncd.iso /aptoncd-mountpoint -o loop

you should run this:

sudo ln -s /aptoncd-mountpoint /media/apt

If it gives you error, saying /media/apt does not exists, create one with this

sudo mkdir /media/apt

Then run the third command of dv5300ea's command(slightly changed):

sudo apt-cdrom add

This should perfectly work.

0

my :

mount -t iso9660 -o loop  /media/Disk1/debian-7.6.0-i386-DVD-1.iso /media/dvd1-mountpoint
mount -t iso9660 -o loop  /media/Disk1/debian-7.6.0-i386-DVD-2.iso /media/dvd2-mountpoint
mount -t iso9660 -o loop  /media/Disk1/debian-7.6.0-i386-DVD-3.iso /media/dvd3-mountpoint
mount -t iso9660 -o loop  /media/Disk1/debian-update-7.6.0-i386-DVD-1.iso /media/dvd4-mountpoint
mount -t iso9660 -o loop  /media/Disk1/debian-update-7.6.0-i386-DVD-2.iso /media/dvd5-mountpoint

echo "deb file:/media/dvd1-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb file:/media/dvd2-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb file:/media/dvd3-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb file:/media/dvd4-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb file:/media/dvd5-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list

echo "deb http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list.d/dotdeb.list

wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | apt-key add -

apt-get update    
apt-get upgrade
apt-get autoremove
0

Slight change to this, helped me get it working especially in a amd64/i386 mixed environment.

** Instead of using the mount command I just permanently mounted the iso in /etc/fstab **

mount -t iso9660 -o loop  /media/Disk1/debian-7.6.0-amd64-DVD-1.iso /media/dvd1-mountpoint
mount -t iso9660 -o loop  /media/Disk1/debian-7.6.0-amd64-DVD-1.iso /media/dvd2-mountpoint
mount -t iso9660 -o loop  /media/Disk1/debian-7.6.0-amd64-DVD-1.iso /media/dvd3-mountpoint 
mount -t iso9660 -o loop  /media/Disk1/debian-7.6.0-i386-DVD-1.iso /media/dvd4-mountpoint
mount -t iso9660 -o loop  /media/Disk1/debian-7.6.0-i386-DVD-2.iso /media/dvd5-mountpoint
mount -t iso9660 -o loop  /media/Disk1/debian-7.6.0-i386-DVD-3.iso /media/dvd6-mountpoint

echo "deb [arch=amd64] file:/media/dvd1-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb [arch=amd64] file:/media/dvd2-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb [arch=amd64] file:/media/dvd3-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb [arch=i386] file:/media/dvd4-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb [arch=i386] file:/media/dvd5-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb [arch=i386] file:/media/dvd6-mountpoint/ wheezy main contrib" >> /etc/apt/sources.list.d/dotdeb.list

echo "deb http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list.d/dotdeb.list

wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | apt-key add -

apt-get update    
apt-get upgrade
apt-get autoremove
0

How to use a .iso image as a CD-ROM/DVD Repository? And how to install packages using the repository?

First create a sources.list file anywhere; like e.g.: /home/$USER/dvd_repo.sources.list by:

echo 'deb [trusted=yes] file:/media/cdrom ./' > /home/$USER/dvd_repo.sources.list

where, /media/cdrom is the mount point of your repository ISO (sudo mkdir /media/cdrom to create if it does not exist; mounted with e.g. sudo mount /home/$USER/wkhtmltopdf_repository.iso /media/cdrom).

After you have your sources.list file, and mounted the repository .ISO file, you should update with:

sudo apt-get -o Dir::Etc::SourceList=/home/$USER/dvd_repo.sources.list update

This skips the default /etc/apt/sources.list. It might take a few moments (took 2 minutes for me) for the repository query to timeout when we are not connected to internet, and if additional repository are configured in sources.list.d directory (I had Waydroid in mine). The log for mine is:

Get:1 file:/media/cdrom ./ InRelease
Ign:1 file:/media/cdrom ./ InRelease
Get:2 file:/media/cdrom ./ Release
Ign:2 file:/media/cdrom ./ Release
Get:3 file:/media/cdrom ./ Packages [2,148 B]
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Ign:6 https://repo.waydro.id lunar InRelease                                   
Ign:6 https://repo.waydro.id lunar InRelease
Ign:6 https://repo.waydro.id lunar InRelease
Err:6 https://repo.waydro.id lunar InRelease
  Could not connect to repo.waydro.id:443 (205.185.118.53). - connect (101: Network is unreachable)
Reading package lists... Done
W: Failed to fetch https://repo.waydro.id/dists/lunar/InRelease  Could not connect to repo.waydro.id:443 (205.185.118.53). - connect (101: Network is unreachable)
W: Some index files failed to download. They have been ignored, or old ones used instead.

Though the available package is not reflected in apt-cache policy pkg_name, you can now successfully install the package with apt-get. E.g. to install the package wkhtmltopdf:

sudo apt-get -o Dir::Etc::SourceList=/home/$USER/dvd_repo.sources.list install wkhtmltopdf

You can override the sources.list.d by:

sudo apt-get -o Dir::Etc::SourceList=/home/$USER/dvd_repo.sources.list -o Dir::Etc::SourceParts=/dev/null update

This overrides both /etc/apt/sources.list and /etc/apt/sources.list.d/ and results in faster update of index files in /var/lib/apt/lists, however all other cached index files are removed which results in not being able to query for available packages in web repositories, until you connect to internet and update the package indexes again. (I've assigned Dir::Etc::SourceParts to /dev/null file while you may assign to an empty existing directory, say, /var/empty/.)

After installation, unmount the ISO file with sudo umount /media/cdrom .


Links:

-1

< Alexare asked: I have all images of Debian, Ubuntu and Ubuntustudio as .iso. How can I use them as repository to install my desired packages with sudo apt-get install package-name? >

my answer:

I open the iso file with file-roller, extract from there the directories '.../dists/' and '.../pool/' to an empty directory (on a hard disk or extraible media, e.g. usb stick) and add to /etc/apt/sources.list:

deb file:/path_to/that_directory distro main [contrib]

Then I open aptitude as root and update the source

Done.

You can add on the media and in sources.list more then one of these files.

Probe it if you like with 'apt-get' instead using aptitude, I don't know if that works.

-1

Salam

Personal Repositories in Ubuntu: https://help.ubuntu.com/community/Repositories/Personal

to add mount point to sourcelist add

deb file:/aptoncd-mountpoint

in general:

deb file:/usr/local/mydebs ./
1
  • That wiki page doesn't exist. Can you explain your commands a little better? Thanks!
    – Seth
    Jan 11, 2015 at 4:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .