Help Center/ Image Management Service/ Best Practices/ Configuring an ISO File as a Local Image Source
Updated on 2025-05-08 GMT+08:00

Configuring an ISO File as a Local Image Source

Context

When you install software on a Linux ECS, the network may be disconnected or resources on the network may be invalid, resulting in software installation failures. In this case, you can configure an ISO file as a local image source to install the software.

Package Managers

Before configuring a local source, you need to determine the package manager to be used. Generally, there are three types of package managers: yum, apt, and zypper.

  • yum is for RHEL-based OSs: RHEL, CentOS, EulerOS, and Fedora.
  • apt is for Debian and Ubuntu.
  • zypper is for SUSE and openSUSE.

Configure a Local Image Source

Configure a local image source by following the instructions in yum, apt, or zypper.

  • yum
    1. Upload the ISO file to the ECS and mount it to the /mnt directory.

      mount XXX.iso /mnt

    2. Enter the /etc/yum.repo.d directory where the yum configuration file is stored and back up all .repo files. Then, create a new .repo configuration file, for example local.repo. Add the following information to the local.repo file:
      [rhel-local]
      name=local
      baseurl=file:///mnt
      enabled=1
      gpgcheck=0

      The /mnt directory specified in the configuration file must be the same as the mounting directory of the ISO file.

    3. Clear yum.

      yum clean all

    4. Generate a new cache.

      yum makecache

  • apt
    1. Upload the ISO file to the ECS and mount it to the /mnt directory.

      mount XXX.iso /mnt

    2. Add the apt cdrom source.

      apt-cdrom -m -d /mnt/ add

    3. View the added source in the configuration file.

      cat /etc/apt/sources.list

    4. Update the source.

      apt-get update

  • zypper
    1. Upload the ISO file to the ECS.
    2. Add the ISO file as the source.

      sudo zypper addrepo iso:/?iso=/media/SOFTWARE/openSUSE-11.4-DVD-i586.iso DVDISO

      In the preceding command:

      • /media/SOFTWARE/openSUSE-11.4-DVD-i586.iso is the location of the ISO file.
      • DVDISO is the source alias.
    3. Check whether the source is successfully added.

      zypper repos

    4. Refresh the source.

      zypper refresh

Examples

The operations in Configure a Local Image Source may be different depending on the OS version. Basically, you need to add a source and refresh it. Debian 10.1.0 and CentOS 8.0 are used as examples to describe how to add a local source.

  • Debian 10.1.0

    Run cat /etc/apt/sources.list to check whether the sources.list file contains a default cdrom source.

    Figure 1 Viewing the source

    The source directs to the CD-ROM drive /dev/cdrom. Debian 10.1.0 provides a soft link to link the CD-ROM drive to /media/cdrom.

    Figure 2 Checking the media directory

    Therefore, mount the ISO file to /media/cdrom.

  • CentOS 8.0
    1. Mount the ISO file to the /mnt directory.
    2. Rename all source files except CentOS-Media.repo in the /etc/yum.repo.d directory as .bak files or move them to another directory.
    3. Modify the CentOS-Media.repo file.
      Figure 3 Modifying the CentOS-Media.repo file

      The modifications in the red box are as follows:

      • Set baseurl to file:///mnt/BaseOS and file:///mnt/AppStream. mnt is the mounting directory of the ISO file. Delete invalid paths from the default configuration, or a checksum error will occur.
      • Change the value of gpgcheck to 0, indicating that the check is not performed.
      • Change the value of enabled to 1 for the configurations to take effect.
    4. Clear yum and generate a new cache.

      yum clean all && yum makecache