In this article, we would discuss how to add ISO image as CD-ROM repository in Ubuntu distribution. The bootable ISO image of Ubuntu distribution contains hundreds of packages. These packages can be installed either during Ubuntu installation or later. It makes sense not to install all the packages available on CD/DVD beforehand. We can install required packages as and when required.
To install the required packages; we have two options available –
- Download packages over internet, or
- Fetch them through ISO image.
Downloading a package over internet is pretty straight-forward. All we need to do is update the repository and then install the relevant packages. For instance, if we want to install Firefox web browser then issue the following in terminal –
sudo apt update sudo apt install firefox
But, installing a package from CD-ROM requires you to add the repository in /etc/apt/sources.list first. Thereafter, we can mount the ISO and fetch the relevant packages. Now, we will discuss each of these operations step-by-step and explain it with examples wherever necessary.
Note: Following operations would require you to have superuser privileges. In case you don’t have one, then contact your System Administrator for assistance.
Use ISO image as CD-ROM repository
There are two methods through which we can add a CD-ROM repository.
Method 1. Manually edit the SourcesList
Firstly, we need to mount the ISO image. Thereafter, we would make relevant entries in /etc/apt/sources.list file.
Make a directory to mount the ISO –
sudo mkdir -p /mnt/mount-iso/
Now, we will mount the ISO image on /mnt/mount-iso/ through mount command –
mount -o loop /path/to/ubuntu-19.10-desktop-amd64.iso /mnt/mount-iso/
Open /etc/apt/sources.list in a text editor, we have used nano.
sudo nano /etc/apt/sources.list
And, add the following entries in /etc/apt/sources.list
deb file:/mnt/mount-iso eoan main
and, run
sudo apt update
At this point you would get the error –
E: The repository ‘file:/mnt/mount-iso eoan Release’ does not have a Release file.
We did this on purpose. If everything has been done as mentioned up till now. Then, you are bound to get the error. Otherwise, there is something amiss. This error basically tells us that release file for Ubuntu distribution is not found on ISO image. To get rid of the issue, we need to add [trusted=yes] in the /etc/apt/sources.list.
Hence, replace the following line –
deb file:/mnt/mount-iso eoan main
with –
deb [trusted=yes] file:/mnt/mount-iso eoan main
And, then do –
sudo apt update
Now, you can install required packages available in CD-ROM.
Additional Info –
You need to mount (mount -o loop /path/to/ubuntu-19.10-desktop-amd64.iso /mnt/mount-iso/
) the ISO image every time you log in to your system. Therefore, to make the mount permanent we need to make the following entries in /etc/fstab file.
Open the file with a text editor –
sudo nano /etc/fstab
And, add following entries –
/path/to/iso/eoan-server-amd64.iso /mnt/mount-iso iso9660 loop,ro,auto 0 0
This will make sure your mount will survive after every reboot.
Method 2. Use apt-cdrom command-line utility.
We need to make a directory on which ISO image will be mounted.
sudo mkdir -p /mnt/mount-iso/
To temporary mount, which survives till next boot –
sudo mount -o loop /path/to/ubuntu-19.10-desktop-amd64.iso /mnt/mount-iso/
To make the mount permanent, we need to append /etc/fstab with following entries –
/path/to/iso/eoan-server-amd64.iso /mnt/mount-iso iso9660 loop,ro,auto 0 0
Now, we will use the command-line utility apt-cdrom to get the relevant entries added in /etc/apt/sources.list
sudo apt-cdrom -m -d=/mnt/mount-iso add
To update the repository –
sudo apt update
And, you can install the relevant packages available in CD-ROM.
In conclusion, we have discussed the two methods available to use ISO image as CD-ROM repository.