How to Create a YUM Local Repository in Linux

|
Facebook
How to Create a YUM Local Repository in Linux

Introduction

How to Create a YUM Local Repository in Linux is an important topic for Linux system administrators who regularly install, update, upgrade, and manage software packages.

In enterprise environments, Linux servers may not always have direct internet access due to security policies, firewall restrictions, or network isolation. In such situations, installing packages from online repositories becomes difficult.

To overcome this challenge, Linux administrators can configure a YUM Local Repository.

A local YUM repository allows administrators to install and manage RPM packages from locally available installation media, ISO images, or custom repository directories without depending on external repositories.

In this hands-on tutorial, we will learn how to create a YUM local repository in Linux using an Oracle Linux ISO image.

We will also cover:

1. Understanding YUM and DNF repositories.

2. Mounting an Oracle Linux ISO image.

3. Configuring BaseOS and AppStream repositories.

4. Refreshing repository metadata.

5. Disabling online repositories.

6. Creating a custom local repository.

7. Adding additional RPM packages.

8. Generating repository metadata using createrepo_c.

9. Installing packages using the local repository.

Now let's start a step-by-step guide on how to create a YUM local repository in Linux on OEL 9.5.

Before configuring a local repository, let's understand what YUM and DNF are.

YUM (Yellowdog Updater Modified) is a package management utility used in RPM-based Linux distributions to install, update, and remove software packages.

DNF (Dandified YUM) is the next-generation package manager and is used by modern Linux distributions, including Oracle Linux 9.

The yum command is also available in Oracle Linux 9 and provides compatibility with the DNF package manager.

A YUM repository is a location that stores RPM packages along with metadata files.

The package manager uses this metadata to identify available packages, package versions, and dependencies during installation.

Repositories can be configured from different sources:

1. Online repositories.

2. Local directories.

3. Mounted ISO images.

4. Internal repository servers.

Oracle Linux installation media contains two important repository components.

BaseOS Repository

  • Contains core operating system packages.
  • Includes essential system utilities and libraries.
  • Provides packages required for the basic operating system.

AppStream Repository

  • Contains additional application packages.
  • Provides application streams and software components.
  • Includes packages required by various applications and services.

Both repositories are important for installing packages and resolving dependencies.

For this practical, we are using Oracle Linux 7.9 installed on Oracle VirtualBox.

ComponentDetails
Operating SystemOracle Linux 9.5
Architecturex86_64
VirtualizationOracle VirtualBox
Package ManagerYUM / DNF
Repository TypeLocal Repository
Repository SourceOracle Linux ISO
Repository ComponentsBaseOS and AppStream

Note: Although this demonstration uses Oracle Linux 9.5, the general concept of configuring a local RPM repository applies to other compatible RPM-based Linux distributions. Repository paths and package manager configurations may vary by distribution and version.

Before configuring the local repository, check the available filesystems and mount points.

Execute:

df -h 

Output:

How to Create a YUM Local Repository in Linux

The df -h command displays filesystem size, used space, available space, and mount points.

Use this information to identify available storage before copying ISO contents or creating a custom repository.

To create a local repository, we first need the Oracle Linux installation ISO.

Attach the Oracle Linux 9.5 ISO to the virtual machine through Oracle VirtualBox storage settings.

Once the ISO is attached, check the available mount points:

df -h

You can also check mounted filesystems using:

findmnt -t iso9660

Output:

Navigate to the mount directory:

cd /run/media/root/OL-9-5-0-BaseOS-x86_64

Check the contents:

ls -lrt

Expected Focus Directories:

BaseOS
AppStream

These directories contain the Oracle Linux installation packages.

Important: Make sure you are using the Oracle Linux installation ISO, not the VirtualBox Guest Additions ISO. They are different ISO images.

Once the Oracle Linux ISO is mounted, we can configure YUM to access the packages directly from the ISO.

YUM/DNF repository configuration files are maintained under:

/etc/yum.repos.d

Create a new repository configuration file:

vi /etc/yum.repos.d/local.repo

Add the following configuration:

[BaseOS]
name=Oracle Linux 9.5 BaseOS
baseurl=file:///run/media/root/OL-9-5-0-BaseOS-x86_64/BaseOS
enabled=1
gpgcheck=0

[AppStream]
name=Oracle Linux 9.5 AppStream
baseurl=file:///run/media/root/OL-9-5-0-BaseOS-x86_64/AppStream
enabled=1
gpgcheck=0

Save and exit the file.

Explanation of repository parameters

ParameterDescription
[BaseOS]Unique repository ID
nameRepository description
baseurlLocation of the repository
file://Specifies a local filesystem repository
enabled=1Enables the repository
gpgcheck=0Disables RPM signature verification

Note: Replace the example ISO path with the actual mount path in your environment.

For production environments, configure GPG verification and trusted repository signing keys instead of disabling package signature verification.

After creating the repository configuration file, refresh the package manager cache.

First, clean the existing cache:

yum clean all

Next, create the repository metadata cache:

yum makecache

This indicates the package manager could access the configured repositories and create the metadata cache.

Now verify whether the local repositories are configured successfully.

Execute:

yum repolist

Output:

[root@dbalab yum.repos.d]# yum repolist
repo id                                                                                                  repo name
AppStream                                                                                         Oracle Linux 9.5 AppStream
BaseOS                                                                                                Oracle Linux 9.5 BaseOS

To display all configured repositories, including disabled repositories, execute:

yum repolist all

Output:

[root@dbalab yum.repos.d]# yum repolist all
repo id                       repo name                                             status
AppStream              Oracle Linux 9.5 AppStream             enabled
BaseOS                     Oracle Linux 9.5 BaseOS                    enabled

This command helps us identify the enabled and disabled repositories.

At this stage, the local BaseOS and AppStream repositories are configured.

By default, Oracle Linux may have online repositories configured.

For example:

  • ol9_baseos_latest
  • ol9_appstream
  • ol9_UEKR7

To use only the local ISO repository, disable the corresponding online repositories.

Open the Oracle Linux repository configuration file:

vi /etc/yum.repos.d/oracle-linux-ol9.repo

Open the UEK repository configuration file:

vi /etc/yum.repos.d/uek-ol9.repo

Locate the following repository sections:

[ol9_baseos_latest]
enabled=1

[ol9_appstream]
enabled=1

[ol9_UEKR7]
enabled=1

Change the enabled parameter to 0:

[ol9_baseos_latest]
enabled=0

[ol9_appstream]
enabled=0

[ol9_UEKR7]
enabled=0

Save the configuration files.

Now clean the repository cache:

yum clean all

Refresh the metadata:

yum makecache

Verify the enabled repositories:

yum repolist

Now only the enabled local BaseOS and AppStream repositories will be listed.

Important: Disabling online repositories is optional. Do this only when you specifically want to use the local repository. Make sure all required dependencies are available locally before attempting package installation.

Create a Custom Local Repository for Additional RPM Packages

Sometimes, the RPM package we need may not be available in the Oracle Linux installation ISO.

For example, while preparing an Oracle Database installation environment, we may need the following package:

oracle-database-preinstall-19c
oracle-database-preinstall-19c

In this situation, we can create a custom local repository and add the required RPM package.

For this practical, we will create a writable repository directory under /repo.

Execute:

mkdir -p /repo/OL9/AppStream

This creates the directory structure for our custom repository.

The mounted ISO is generally read-only.

Therefore, we will copy the AppStream contents into our writable repository directory.

Execute:

cp -av /run/media/root/OL-9-5-0-BaseOS-x86_64/AppStream/. /repo/OL9/AppStream/

This copies the existing AppStream packages and repository metadata into the new directory.

You can download the package oracle-database-preinstall-19c from this online repository link.

Assume that the Oracle Database preinstallation RPM has already been downloaded into /root.

Copy the RPM into the custom repository:

cp /root/oracle-database-preinstall-19c*.rpm /repo/OL9/AppStream/

Output:

Copy the additional RPM package

Now the additional RPM package is available in the custom repository directory.

The createrepo_c utility is used to generate repository metadata for RPM packages.

Install it using:

yum install -y createrepo_c

Make sure the enabled repositories provide the required package and its dependencies.

yum install -y createrepo_c

After copying the additional RPM package, we need to update the repository metadata.

Execute:

createrepo_c --update /repo/OL9/AppStream/

This command generates or updates the repository metadata.

The metadata allows YUM/DNF to identify the additional RPM package when searching the repository.

createrepo_c --update /repo/OL9/AppStream/

Create a new repository configuration file:

vi /etc/yum.repos.d/local.repo

Add the following configuration:

[local-appstream]
name=Oracle Linux 9.5 Local AppStream
baseurl=file:///repo/OL9/AppStream
enabled=1
gpgcheck=0

Save and exit the file.

Execute the following commands:

yum clean all
yum makecache

Now verify the configured repositories:

yum repolist
[root@dbalab yum.repos.d]# yum repolist
repo id                                                                                  repo name
AppStream                                                                          Oracle Linux 9.5 AppStream
BaseOS                                                                                 Oracle Linux 9.5 BaseOS
local-appstream                                                                 Oracle Linux 9.5 Local AppStream

The custom repository should appear in the repository list.

Now we can install the additional package using YUM:

yum install -y oracle-database-preinstall-19c

YUM will search the enabled repositories for the requested package and attempt to resolve its dependencies.

Important: The Oracle Database preinstallation RPM may require additional dependencies. Keep the original BaseOS and AppStream repositories enabled and available so that YUM/DNF can resolve the dependencies.

Also ensure that the preinstallation RPM is compatible with your operating system version.

Difference Between a Local Repository and a Custom Repository

Local ISO RepositoryCustom Local Repository
Uses packages available on installation mediaUses packages copied into a writable directory
Can be configured directly from a mounted ISORequires a local directory
Contains the original installation repository metadataMetadata can be generated or updated using
createrepo_c
Useful for offline OS package installationUseful for adding additional RPM packages
Generally read-only when using ISO mediaWritable and can be maintained by administrators

Important YUM Commands

Here are some useful commands that Linux administrators regularly use while managing repositories.

CommandPurpose
df -hCheck filesystem usage
mountDisplay mounted filesystems
findmnt -t iso9660Identify mounted ISO images
ls -lrtList directory contents
yum clean allClean package manager cache
yum makecacheCreate repository metadata cache
yum repolistDisplay enabled repositories
yum repolist allDisplay all repositories
yum install -y package_nameInstall a package
yum list availableList available packages
rpm -qaList installed RPM packages
createrepo_c /path/to/repositoryGenerate repository metadata
createrepo_c –update /path/to/repositoryUpdate repository

Conclusion

In this hands-on tutorial, we learned how to create a YUM local repository in Linux using an Oracle Linux ISO image.

We configured BaseOS and AppStream repositories, refreshed the repository metadata, disabled online repositories, and created a custom local repository for additional RPM packages.

We also learned how to use the createrepo_c utility to generate repository metadata and install additional packages using the local repository.

Configuring a local YUM repository is particularly useful in enterprise environments where Linux servers operate without direct internet access or where administrators need controlled package installation.

A properly configured local repository simplifies Linux package management, improves software installation consistency, and reduces dependency on external repositories.

Related Articles

Oracle Linux 9.5 Installation on VirtualBox 7

How to Install Oracle 19c Binaries on Linux

Oracle Database 19c Installation Guide

👍 Enjoyed This Practical?

If you found this practical useful, please consider sharing it with your friends and colleagues.

🔗 Follow me on LinkedIn | 📢 Join my Telegram Community

💼 Need Database Consulting or Have a Project?

Looking for help with Oracle Database, MySQL, OCI, database migration, performance tuning, backup and recovery, or automation? Let's connect to discuss your requirements and explore how I can help.

👉 Explore Database Consulting Services | Discuss Your Project

💬 What would you like me to cover next? Share your suggestions in the comments.

Thank you for reading and supporting the blog! 🙏

DBAStack

I’m a database professional with more than 10 years of experience working with Oracle, MySQL, and other relational technologies. I’ve spent my career building, optimizing, and maintaining databases that power real-world applications. I started DBAStack to share what I’ve learned — practical tips, troubleshooting insights, and deep-dive tutorials — to help others navigate the ever-evolving world of databases with confidence.

Keep Reading

Installation of VirtualBox Guest Additions
|
by DBAStack
How to Install Oracle Virtual Box
|
by DBAStack
Installation of Windows 11 on VirtualBox
|
by DBAStack

Leave a Comment