Local YUM repository is the place where the rpm packages for Redhat or CentOS are stored and distributed to client servers for software installation and OS updates.
This local repository lets you save internet bandwidth as well as the time for downloading packages from the internet.
Here, we will go through steps to create local YUM repository on RHEL 8 for RHEL 8 using DVD.
New Repository in RHEL 8
Red Hat Enterprise Linux 8 is split across two repositories,
- BaseOS
- Application Stream (AppStream)
Packages in BaseOS is intended to provide the core set of the underlying OS functionality that provides the foundation for all type installations.
Packages in Application Stream includes user space applications, runtime languages, and databases in support of the varied workloads and use cases.
Create Source
Repository’s source can be created either using the createrepo package or mounting the DVD on the directory. Mounting the DVD/CD ROM will help you save the space on HDD used by being copied to HDD.
Here, mount the DVD ROM on any directory of your wish. For testing, I will mount it on /cdrom.
mkdir /cdrom mount /dev/cdrom /cdrom
Create a .repo file
Before creating a <name>.repo file, move the existing files present in /etc/yum.repos.d/directory to/tmp, if no longer required.
mv /etc/yum.repos.d/*.repo /tmp/
Create a repo file called local.repo under /etc/yum.repos.d directory.
vi /etc/yum.repos.d/local.repo
Base OS
[LocalRepo_BaseOS] name=LocalRepository_BaseOS baseurl=file:///cdrom/BaseOS enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
App Stream
[LocalRepo_AppStream] name=LocalRepository_AppStream baseurl=file:///cdrom/AppStream enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Details:
[LocalRepo] | Name of the Section |
name | Name of the repository |
baseurl | Location of the package |
Enabled | Enable repository |
gpgcheck | Enable secure installation (gpgcheck is optional (If you set gpgcheck=0, there is no need to mention gpgkey) |
gpgkey | Location of the key |
Install Packages from Local YUM repository
yum clean all
Let’s install the telnet package from the local repository.
yum install vsftpd
The output will be like below.
When you give yes to download the package, it will prompt you to accept gpg signing key.
LocalRepository_AppStream 3.1 MB/s | 3.2 kB 00:00 LocalRepository_BaseOS 2.7 MB/s | 2.7 kB 00:00 Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: vsftpd x86_64 3.0.3-28.el8 LocalRepo_AppStream 180 k Transaction Summary ================================================================================ Install 1 Package Total size: 180 k Installed size: 356 k Is this ok [y/N]: y Downloading Packages: warning: /cdrom/AppStream/Packages/vsftpd-3.0.3-28.el8.x86_64.rpm: Header V3 RSA /SHA256 Signature, key ID fd431d51: NOKEY LocalRepository_AppStream 177 kB/s | 5.0 kB 00:00 Importing GPG key 0xFD431D51: Userid : "Red Hat, Inc. (release key 2) <security@redhat.com>" Fingerprint: 567E 347A D004 4ADE 55BA 8A5F 199E 2F91 FD43 1D51 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release Is this ok [y/N]: y Key imported successfully Importing GPG key 0xD4082792: Userid : "Red Hat, Inc. (auxiliary key) <security@redhat.com>" Fingerprint: 6A6A A7C9 7C88 90AE C6AE BFE2 F76F 66C3 D408 2792 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release Is this ok [y/N]: y Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : vsftpd-3.0.3-28.el8.x86_64 1/1 Running scriptlet: vsftpd-3.0.3-28.el8.x86_64 1/1 Verifying : vsftpd-3.0.3-28.el8.x86_64 1/1 Installed products updated. Installed: vsftpd-3.0.3-28.el8.x86_64 Complete!
Conclusion
That’s All. You have successfully configured the local yum repository on the machine.