Share on Social Media

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

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:

  1. Speed: Accessing packages from a local server is typically faster than downloading them from the internet.
  2. Reliability: A local repository can provide more reliable package access, especially in environments with limited or intermittent internet connectivity.
  3. Control: Administrators can control which packages and versions are available, ensuring consistency across multiple systems.
  4. 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 9 servers in your Data Center.

Here, we will show you the step by step process to setup a local yum repository in Linux 9.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

745772 0021show?id=oLRJ54lcVEg&offerid=1074652.745772&bids=1074652

Environment Specification

We are using a Rocky Linux 9 minimal server with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – Rocky Linux 9.0 (Blue Onyx)
  • Hostname –
  • IP Address – /24

Gathering Linux Server Information

By using a ssh client, connect with your as root user.

Check the versions of your Linux Kernel and Linux operating system used in this tutorial.

# uname -r

# cat /etc/rocky-release
Rocky Linux release 9.0 (Blue Onyx)

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).

Rocky Linux Downloads
Rocky Linux Downloads

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 auto-mount your ISO file, you need to add a directive in /etc/fstab file.

Open /etc/fstab file by using vim text editor.

# vi /etc/fstab

Add following directive in this file to auto-mount ISO file.

/root/Rocky-9.0-x86_64-dvd.iso /var/www/html/repo       iso9660 defaults        0 0

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.

Create Local Yum Repository

Create a directory and then move the existing yum repo files in it.

# mkdir /etc/yum.repos.d/old
# mv /etc/yum.repos.d/rocky* /etc/yum.repos.d/old/

There is a repo file is available in the Rocky Linux ISO. You can use it after some amendments.

By using cp command copy media.repo file at /etc/yum.repos.d directory.

# 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.

name=Rocky Linux 9.0 - BaseOS

name=Rocky Linux 9.0 - 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.

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/ → /usr/lib/systemd/system/httpd.service.

Allow the Apache service in Linux firewall.

# firewall-cmd --permanent --add-service=http
# firewall-cmd --reload

Create a repo file with following contents and then copied at /etc/yum.repos.d/ directory of other Rocky Linux 9 servers to let them use your local yum repository.

name=Rocky Linux 9.0 - BaseOS

name=Rocky Linux 9.0 - AppStream

To improve your Linux command line skill, we recommend that you should read Linux for Beginners (PAID LINK) by Ethem Mining (Author).

Also Read: 
Create Local Yum Repository from ISO in CentOS 8
Create Local Yum Repository from ISO in CentOS 7


Thank you for following this guide on creating a local YUM repository in Rocky Linux 9. If you need further assistance or personalized support, feel free to check out my Fiverr profile for professional help. Happy computing!

Leave a Reply