Setup redhat 9 local yum/dnf repository without internet connection
The Environment that will be provided to you in the Redhat Certification Exams are offline.
Repo allows you to install desired packages. In this case, we will create a local, offline Repo. Similar to the way the RHCE & RHCSA Certification Lab will be setup.
Note:
All the repos are already in the iso image you used to install the OS, in this case rhel-9.2-x86_64-dvd.iso
Packages are in AppStream & BaseOS Directories in your ISO File. While updating the location of the repo use the parents folder /localrepo/BaseOS/
I recommend mounting the ISO permanently to the VM instead of copying the contents of the ISO to the VM which will only make your VM bigger in size.
Error if the Repo is not configured.
root@server1 ~]# dnf install curl
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Error: There are no enabled repositories in "/etc/yum.repos.d", "/etc/yum/repos.d", "/etc/distro.repos.d".
Steps
Check ISO mount status in GUI: Go to Files in Redhat Linux. You’ll not find the ISO Image mounted
Check ISO mount status in CLI: enter the command
df -Th.
You’ll not find the ISO Image mounted.Add ISO: Go to the Virtual Machine Menu, Devices, Optical Drives, Choose/create a disk image. In the VM - Optical Disk Selector Window click Add, Browse & single click to select your iso image and click Open
Verify if ISO is added or not. In GUI:
Verify if ISO is added or not. In CLI:
df -Th.
ISO is mounted under the/dev/sr0
Filesystem & Mount point/run/media/user1/RHEL-9-2-0-BaseOS-x86_64
Check the contents of the ISO image :
ls /run/media/user1/RHEL-9-2-0-BaseOS-x86_64
Note: Instead of copying the contents of the ISO, mount it to a local directory created by you.
Create a local directory to mount the ISO image Filesystem:
mkdir /localrepo
Mount the ISO Image Filesystem to the local directory:
mount /dev/sr0 /localrepo/
Check the new mount point for the ISO Filesystem
/dev/sr0
, in this case/localrepo
To mount permanently update the line below in the /etc/fstab File
/dev/sr0 /localrepo iso9600 defaults 0 0
Note: Packages are in the AppStream & BaseOS Directories of the ISO.
Create your own repo file with the *.repo extension:
vim /etc/yum.repos.d/local.repo
Update the config for both AppStream & BaseOS.
[root@server1 ~]# cat /etc/yum.repos.d/local.repo [BaseOS] #Mandatory Configuration name=BaseOS-RHEL9 enabled=1 baseurl=file:///localrepo/BaseOS/ #Optional Security Configuration gpgcheck=1 gpgkey=file:////etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [AppStream] #Mancatory Configuration name=AppStream-RHEL9 enabled=1 baseurl=file:///localrepo/AppStream/ #Optional Security Configuration gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Validate if the Repo is enabled & list of local repo configured:
yum repolist all.
Validate if Repo is correctly configured by installing a package:
dnf install -y httpd
~End of Guide~