create yum repository from iso dvd image

How to Create Yum Repository in RHEL 7 using ISO image

Yum is a popular package manager that allows you to easily install, upgrade & delete software packages in RHEL/CentOS systems. It allows you to download software from official as well as unofficial software repositories. You can also create yum repository in RHEL using ISO image or DVD. In this article, we will learn how to do this. It is useful if you want to install packages from ISO or DVD image.


How to Create Yum Repository in RHEL 7 using ISO image

Here are the steps to create yum repository in RHEL using ISO image.

Let us say you have rhel7.iso ISO image. Open terminal and run the following command to mount it to /mnt folder. Unless you mount the ISO or DVD you cannot access it in Linux.

# mount -o loop rhel7.iso /mnt

Run the following command to copy media.repo file from mounted directory /mnt to /etc/yum.repos.d/ and name it as rhel7.repo. This file generally exists in almost every ISO image.

# cp /mnt/media.repo /etc/yum.repos.d/rhel7.repo

Change the permission of repository file.

# chmod 644 /etc/yum.repos.d/rhel7.repo

Modify the repo file and change parameter gpgcheck=0 to gpgcheck=1. Also add the following 3 lines to it. It basically provides the location of GPG key, as well as base URL for yum repo packages.

enabled=1
baseurl=file:///mnt/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

After you have added the above lines, your final repo file should look like the following. mediaid may look different.

[InstallMedia]
name=DVD for Red Hat Enterprise Linux 7.3 Server
mediaid=9859238196.834790
metadata_expire=-1
gpgcheck=1
cost=500
enabled=1
baseurl=file:///mnt/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Ensure you clear all related yum caches using the following commands.

# yum clean all
# subscription-manager clean

Verify if you can list packages from your newly created repo, using the following commands.

# yum  --noplugins list
# yum repolist -v

In this article, we have learnt how to create yum repository from ISO image. The basic idea is to mount the ISO/DVD to a local folder and then point Yum to its location. It is useful if you want to install packages from an ISO or DVD image to your system.

Also read:

How to Setup Local Yum Repository in CentOS/RHEL
How to List Files Installed From RPM or DEB Package
How to Change Console Fonts in Ubuntu Server
How to Set Password for Single User Mode
How to Change Kernel Parameters At Runtime

Leave a Reply

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