Learn how to create local YUM repository in Rocky Linux 9 with our step-by-step guide. Optimize package management and improve installation speeds for your enterprise environment. #centlinux #linux #yum
Table of Contents
What is Local Yum Repository?
A local YUM (Yellowdog Updater, Modified) repository is a storage location on a local machine or a local network where RPM (Red Hat Package Manager) packages are stored. This repository can be accessed and used by YUM to install, update, and manage software packages on Linux systems such as Rocky Linux, CentOS, and Red Hat Enterprise Linux.
Creating a local YUM repository can provide several benefits:
- Speed: Accessing packages from a local server is typically faster than downloading them from the internet.
- Reliability: A local repository can provide more reliable package access, especially in environments with limited or intermittent internet connectivity.
- Control: Administrators can control which packages and versions are available, ensuring consistency across multiple systems.
- Security: Using a local repository can reduce exposure to external threats by limiting the need to download packages from public repositories.
Problem Definition
Rocky Linux and other RPM based Linux distros, are delivered with standard yum repositories that serve software packages over the Internet.
But in some scenarios your are not able to connect your Linux server to the Internet, thus you cannot use the Linux package manager for software installation. In such a scenario, you have to install individual software packages using rpm command and resolve the dependencies manually.
Alternatively, you can setup a local yum repository from ISO file. And then you can use this yum repository with all the Rocky Linux servers in your Data Center. Here, we will show you the step by step process to setup a local yum repository in Linux.
Recommended Training: Linux Administration: The Complete Linux Bootcamp in 2025 from Andrei Dumitrescu, Crystal Mind Academy
Environment Specification
We are utilizing a minimal installation of Rocky Linux 9 as our base server to demonstrate this setup. The server has been configured with the following specifications to ensure optimal performance and compatibility for the tasks outlined in this guide:
- CPU – 3.4 Ghz (2 cores)
- Memory – 2 GB
- Storage – 20 GB
- Operating System – Rocky Linux 9.0 (Blue Onyx)
- Hostname – local-yum-repo.centlinux.com
- IP Address – 192.168.116.131 /24
This minimal server setup provides a lightweight and efficient environment, making it an ideal starting point for tasks such as software installations, server configurations, and setting up local repositories. Minimal installations not only reduce unnecessary system overhead but also offer greater control over the components installed on your server.
By using these specifications, you can replicate this setup in your own environment to achieve similar results. Feel free to adjust the resources according to your project requirements or the scale of your deployment.
NSPENCM 85W Mac Book Pro Charger, Replacement AC 85w 2T-Tip Connector Power Adapter,Laptop Charger Compatible with MacBook pro & Mac Book Pro 13 inch-15 inch Retina After Mid 2012
$18.90 (as of January 28, 2025 14:41 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Gathering Linux Server Information
By using a ssh client, connect with your linux-yum-repo.centlinux.com as root user.
To begin, connect to your Linux server, linux-yum-repo.centlinux.com
, as the root user using any SSH client of your choice.
Once logged in, verify the versions of the Linux Kernel and the operating system running on the server. This step is essential to ensure compatibility with the software and services you plan to install or configure. You can check the Kernel version by running the command:
# uname -r 5.14.0-70.13.1.el9_0.x86_64 # cat /etc/rocky-release Rocky Linux release 9.0 (Blue Onyx)
This will provide you with detailed information about the Kernel and operating system versions, which is useful for troubleshooting or ensuring you are following the correct steps based on your system environment.
Check the already enabled yum repositories in your Linux operating system.
# dnf repolist repo id repo name appstream Rocky Linux 9 - AppStream baseos Rocky Linux 9 - BaseOS extras Rocky Linux 9 - Extras
Download Rocky Linux 9 ISO
Rocky Linux is free to download. You can get it from Official website of Rocky Enterprise Software Foundation (RESF).
We have copied the downloaded ISO file in the home directory of root user i.e. (/root). Let’s execute ls command to check this.
# ls ~ anaconda-ks.cfg Rocky-9.0-x86_64-dvd.iso
Mount Rocky Linux 9 ISO
Create a directory to mount the Rocky Linux ISO. It is better to create the repo directory within Apache document root, so you can later publish this directory to the network for other Linux server in your Data Center.
# mkdir -p /var/www/html/repo
To ensure your ISO file is automatically mounted at system startup, you need to add the appropriate configuration directive in the /etc/fstab
file. The /etc/fstab
file is a critical system file used to define how and where various disk partitions, devices, or filesystems are mounted.
To begin, open the /etc/fstab
file using a text editor, such as vim
, which is widely used for editing system files on Linux. Follow these steps:
# vi /etc/fstab
Once the file is open, navigate to an empty line at the bottom of the file to avoid overwriting any existing configurations. Add the appropriate directive for your ISO file.
/root/Rocky-9.0-x86_64-dvd.iso /var/www/html/repo iso9660 defaults 0 0
After adding the directive, save and close the file. In vim
, you can do this by pressing Esc
, typing :wq
, and hitting Enter
.
Execute the following command to mount all the entries from /etc/fstab file.
# mount -a mount: /var/www/html/repo: WARNING: source write-protected, mounted read-only.
Linux for Beginners: An Introduction to the Linux Operating System and Command Line
$2.99 (as of January 28, 2025 14:41 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Create Local Yum Repository
Start by creating a directory where you will store all the existing YUM repository configuration files. Choose a logical location to keep it organized. For example, you can create a directory named old
under /etc/yum.repos.d/
, which is the default location for YUM repository files.
Use the following command to create the directory:
# mkdir /etc/yum.repos.d/old # mv /etc/yum.repos.d/rocky* /etc/yum.repos.d/old/
The Rocky Linux ISO contains a repository file named media.repo
that can be utilized as a local YUM repository after making a few modifications. This file serves as the basis for configuring the repository to access packages from the ISO image.
Once you locate the media.repo
file, you need to copy it to the default directory where YUM repository configuration files are stored, /etc/yum.repos.d/
. Use the cp
command to accomplish this:
# cp /var/www/html/repo/media.repo /etc/yum.repos.d/
Now edit media.repo file by using vim text editor.
# vi /etc/yum.repos.d/media.repo
Update the content of this file as follows.
[InstallMedia-BaseOS] name=Rocky Linux 9.0 - BaseOS mediaid=1657031221.5900638 metadata_expire=-1 gpgcheck=0 cost=500 baseurl=file:///var/www/html/repo/BaseOS [InstallMedia-AppStream] name=Rocky Linux 9.0 - AppStream mediaid=1657031221.5900638 metadata_expire=-1 gpgcheck=0 cost=500 baseurl=file:///var/www/html/repo/AppStream
Remove the yum meta data by executing following dnf command.
# dnf clean all 20 files removed
Build yum cache for your local yum repository.
# dnf makecache Rocky Linux 9.0 - BaseOS 3.9 MB/s | 1.7 MB 00:00 Rocky Linux 9.0 - AppStream 14 MB/s | 6.0 MB 00:00 Last metadata expiration check: 0:00:01 ago on Thu 21 Jul 2022 10:50:46 AM CDT. Metadata cache created.
MOSAHOLL Wrist Strap for Switch Joycon – 2 Pack Lanyard Replacement Parts Accessories for Joy Con Joy-Con Controller
$9.99 (as of January 27, 2025 14:47 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Publish Your Local Yum Repository
Your local yum repository has been configured successfully. But to maximum utilization, you have to publish your repository to the network by using Apache web server, so other Linux servers in your Data Center can use it as well.
Install Apache web server by executing dnf command.
# dnf install -y httpd
Enable and start Apache web server.
# systemctl enable --now httpd.service Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Allow the Apache service in Linux firewall.
# firewall-cmd --permanent --add-service=http success # firewall-cmd --reload success
To set up your local YUM repository for use across multiple Rocky Linux servers, you need to create a repository configuration file. This file will contain the necessary settings for your local repository, allowing other servers to access and utilize the repository for package installations and updates.
[InstallMedia-BaseOS]
name=Rocky Linux 9.0 - BaseOS
mediaid=1657031221.5900638
metadata_expire=-1
gpgcheck=0
cost=500
baseurl=http://local-yum-repo.centlinux.com/repo/BaseOS
[InstallMedia-AppStream]
name=Rocky Linux 9.0 - AppStream
mediaid=1657031221.5900638
metadata_expire=-1
gpgcheck=0
cost=500
baseurl=http://local-yum-repo.centlinux.com/repo/AppStream
Once the file is created, copy it to the /etc/yum.repos.d/
directory on all other Rocky Linux 9 servers that should use the local repository.
Also Read:
Create Local Yum Repository from ISO in CentOS 8
Create Local Yum Repository from ISO in CentOS 7
Conclusion
Setting up a local Yum repository on Rocky Linux provides a reliable and efficient way to manage and distribute software packages within your environment. By following the steps in this guide, you’ve learned how to copy RPM packages, configure repository files, and validate your setup to ensure proper package management.
A local Yum repository not only saves bandwidth but also ensures faster installations and updates, especially in environments with multiple systems. It’s an excellent solution for organizations that require a controlled and stable repository for software distribution.
With your local repository configured, you can now easily manage software packages and dependencies for your servers without relying on external internet access. This is particularly useful for secure or isolated networks.
For ongoing maintenance, remember to periodically update your repository with the latest packages and metadata. Congratulations on successfully creating a local repository on Rocky Linux!
Struggling with AWS or Linux server issues? I specialize in configuration, troubleshooting, and security to keep your systems performing at their best. Check out my Fiverr profile for details.