How to Create Local Yum or DNF Repository from DVD or ISO on RHEL 9
In this tutorial, we will describe how to create a local yum/dnf repository on RHEL 9 using DVD or ISO file step by step.
Setup yum/dnf repository for locally-mounted DVD on Red Hat Enterprise 9
Mount the RHEL installation ISO to a directory like /opt/RHEL-9, e.g.:
mkdir -p /opt/RHEL-9 mount -o loop rhel-baseos-9.0-x86_64-dvd.iso /opt/RHEL-9
If you use DVD media, you can mount like below /opt/RHEL-9, e.g.:
mkdir -p /opt/RHEL-9 mount /dev/sr0 /opt/RHEL-9
Create Repo File in ‘/etc/yum.repos.d/’ Directory
Create a repo file with name "rhel9-local.repo" under the folder /etc/yum.repos.d/ with following content
Create a repo file with name "rhel9-local.repo" under the folder /etc/yum.repos.d/ with following content
sudo vi /etc/yum.repos.d/rhel9-local.repo
Following Repo content
[Local-BaseOS] name=Red Hat Enterprise Linux 9 - BaseOS metadata_expire=-1 gpgcheck=1 enabled=1 baseurl=file:///opt/RHEL-9/BaseOS/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [Local-AppStream] name=Red Hat Enterprise Linux 9 - AppStream metadata_expire=-1 gpgcheck=1 enabled=1 baseurl=file:///opt/RHEL-9/AppStream/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Finnaly Save and close the file.
To Verify Repo content File output will be
cat /etc/yum.repos.d/rhel9-local.repo [Local-BaseOS] name=Red Hat Enterprise Linux 9 - BaseOS metadata_expire=-1 gpgcheck=1 enabled=1 baseurl=file:///opt/RHEL-9/BaseOS/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [Local-AppStream] name=Red Hat Enterprise Linux 9 - AppStream metadata_expire=-1 gpgcheck=1 enabled=1 baseurl=file:///opt/RHEL-9/AppStream/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Flush Yum/DNF & Subscription Manager Cache
Execute following commands to clean yum or dnf and subscription manager cache.:
sudo dnf clean all sudo subscription-manager clean
To Disable Red Hat subscription manager warning message
In the above output, we are getting a warning message ‘This system is not registered with an entitlement’. So, if you want to disable this warning message, edit the file ‘/etc/yum/pluginconf.d/subscription-manager.conf’ , change the parameter ‘enabled=1’ to ‘enabled=0’.
sudo vi /etc/yum/pluginconf.d/subscription-manager.conf
Save and exit the file.
For Test Install any rpm Packages using Local Repository
Now we are all set to test our local repository. Run beneath command to view configure repository.
sudo dnf repolist
Now, You can Install packages using yum/dnf command via above configure local repository.
sudo dnf install createrepo_c
Output,
[root@localhost ~]# sudo dnf install createrepo_c Last metadata expiration check: 0:08:17 ago on Tue 21 Jun 2022 07:24:51 PM +06. Dependencies resolved. ===================================================================================================================================================== Package Architecture Version Repository Size ===================================================================================================================================================== Installing: createrepo_c x86_64 0.17.7-4.el9_0 Local-BaseOS 81 k Installing dependencies: createrepo_c-libs x86_64 0.17.7-4.el9_0 Local-BaseOS 100 k Transaction Summary ===================================================================================================================================================== Install 2 Packages Total download size: 180 k Installed size: 441 k Is this ok [y/N]: y Downloading Packages: (1/2): createrepo_c-0.17.7-4.el9_0.x86_64.rpm 80 kB/s | 81 kB 00:01 (2/2): createrepo_c-libs-0.17.7-4.el9_0.x86_64.rpm 91 kB/s | 100 kB 00:01 ----------------------------------------------------------------------------------------------------------------------------------------------------- Total 164 kB/s | 180 kB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : createrepo_c-libs-0.17.7-4.el9_0.x86_64 1/2 Installing : createrepo_c-0.17.7-4.el9_0.x86_64 2/2 Running scriptlet: createrepo_c-0.17.7-4.el9_0.x86_64 2/2 Verifying : createrepo_c-libs-0.17.7-4.el9_0.x86_64 1/2 Verifying : createrepo_c-0.17.7-4.el9_0.x86_64 2/2 Installed products updated. Installed: createrepo_c-0.17.7-4.el9_0.x86_64 createrepo_c-libs-0.17.7-4.el9_0.x86_64 Complete! [root@localhost ~]#
Conclusion
In this tutorial, Setup yum/dnf repository for locally-mounted DVD on Red Hat Enterprise 9. Above output confirms that createrepo_c package along with its dependencies are installed successfully via locally configured yum or dnf repository.