How to Set Up a Local Yum/DNF Repository on CentOS 8

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

In this Article we will learn How to Set Up a Local Yum/DNF Repository on CentOS 8. Local repository is used to store the rpm packages for CentOS 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.

Local Yum/DNF Repository on CentOS 8

Mount the CentOS 8 ISO file using the following command:

mount CentOS-8-x86_64-1905-dvd1.iso /opt
cd /opt
ls

Now the ISO file is mounted use the following command to copy media.repo file to /etc/yum.repos.d/ directory.

cp -v /opt/media.repo  /etc/yum.repos.d/centos8.repo

Then, assign the proper permissions to /etc/yum.repos.d/ directory using the following command:

chmod 644 /etc/yum.repos.d/centos8.repo

Now, Edit the configurations using the following command:

nano etc/yum.repos.d/centos8.repo

Remove all the existing configurations in above opened file and add the following configurations:

[InstallMedia-BaseOS]
name=CentOS Linux 8 - BaseOS
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///opt/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[InstallMedia-AppStream]
name=CentOS Linux 8 - AppStream
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///opt/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

Save and quit the file.

Now, that the Repo file is Updated with new configuration use the following command to clear YUM / DNF cache:

dnf clean all

Use dnf or yum repolist command to verify whether these commands are getting packages from Local repositories.

dnf repolist

Now, open the configuration file “/etc/yum/pluginconf.d/subscription-manager.conf” and set enabled parameter to 1 as shown below:

nano /etc/yum/pluginconf.d/subscription-manager.conf

Now we will install Nginx web server to check if packages are being downloaded and installed using local YUM / DNF Repository:

dnf install nginx
Local Yum/DNF Repository
Local Yum/DNF Repository

Local YUM / DNF repository has been set up successfully.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Mel
Melhttps://unixcop.com
Unix/Linux Guru and FOSS supporter

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook