We will create local yum repository with DVD iso on RHEL | Centos for systems where internet is not available.
Download RHEL/Centos ISO
For downloading RHEL ISO please access Red Hat official download page. For downloading CentOS refer
Once ISO is downloaded, upload it to the server where you want to create the local repository.
[root@master2 ~]$ ls -ltrh
total 9.9G
-rwxrwxrwx 1 nobody kvm 4.4G Feb 5 08:52 CentOS-7-x86_64-DVD-2009.iso
-rw-r--r-- 1 ved ved 4.3G Mar 9 14:57 rhel-server-7.9-x86_64-dvd.iso
Mount ISO File on Linux
Create the mount point directory on Linux
[root@master2 ~]$ sudo mkdir /mnt/ISO
Mount the ISO file on Linux
[root@master2 ~]$ sudo mount -o loop rhel-server-7.9-x86_64-dvd.iso /mnt/ISO/
mount: /dev/loop0 is write-protected, mounting read-only
Once dvd is mounted, goto the /mnt/ISO and list the files in the ISO directory
[root@master2 ~]# cd /mnt/ISO/
[root@master2 ISO]# ls
addons EULA GPL isolinux media.repo repodata RPM-GPG-KEY-redhat-release
EFI extra_files.json images LiveOS Packages RPM-GPG-KEY-redhat-beta TRANS.TBL
We can copy the content of /mnt/ISO on some local directory or we can use same directory for creating the local yum repository.
Create local yum repository with DVD iso
We will now create the yum configuration file for our yum repository using vim inside /etc/yum.repos.d/ directory
[root@master2 ISO]# vim /etc/yum.repos.d/rhel-local.repo
[RHEL-7.9-Local-Repo]
name = RHEL 7.9 Local Repository
baseurl = file:///mnt/ISO
# Replace /mnt/ISO if you have copied the ISO directory content to some other directory
gpgcheck = 0
enabled = 1
Verify the newly created Repository
[root@master2 ISO]# yum repolist
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
RHEL-7.9-Local-Repo | 2.8 kB 00:00:00
(1/2): RHEL-7.9-Local-Repo/group | 628 kB 00:00:00
(2/2): RHEL-7.9-Local-Repo/primary | 2.1 MB 00:00:00
RHEL-7.9-Local-Repo 5230/5230
repo id repo name status
RHEL-7.9-Local-Repo RHEL 7.9 Local Repository 5,230
Install packages from the local yum repository
[root@master2 ISO]# yum install wget
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
RHEL-7.9-Local-Repo
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================
Installing:
wget x86_64 1.14-18.el7_6.1 RHEL-7.9-Local-Repo 547 k
Transaction Summary
==============================================================================================================================
Install 1 Package
Total download size: 547 k
Installed size: 2.0 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wget-1.14-18.el7_6.1.x86_64 1/1
Verifying : wget-1.14-18.el7_6.1.x86_64 1/1
Installed:
wget.x86_64 0:1.14-18.el7_6.1
Complete!
Conclusion
We have successfully created local yum repository with DVD iso and also installed wget package using the local yum repository