Operations 5 min read

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

This guide walks through configuring a local yum repository on CentOS 8 by creating a mount point, mounting an ISO (via CD/DVD or loopback), backing up existing repo files, writing a new repo configuration, cleaning the cache, enabling auto‑mount at boot, and introduces DNF with essential commands.

Open Source Linux
Open Source Linux
Open Source Linux
How to Set Up a Local Yum Repository on CentOS 8 Using DNF

CentOS 8 replaces yum with dnf as the package manager, but dnf remains compatible with yum configuration files and commands.

Configuring a Local Yum Repository

1. Create a mount point mkdir -p /mnt/cdrom 2. Mount the ISO image

Two methods:

(1) Using a physical CD/DVD (e.g., in VMware Workstation) mount /dev/cdrom /mnt/cdrom Verify the mount by listing files.

(2) Using an ISO file

mount -o loop /opt/CentOS-8-x86_64-1905-dvd1.iso /mnt/cdrom

3. Create the local yum repository file

# Backup existing repo files
cd /etc/yum.repos.d/
mkdir repo_bak
mv *.repo repo_bak/

# Create centos8.repo
[c8-media-AppStream]
name=AppStream
baseurl=file:///mnt/cdrom/AppStream
gpgcheck=0
enabled=1

[c8-media-BaseOS]
name=BaseOS
baseurl=file:///mnt/cdrom/BaseOS
gpgcheck=0
enabled=1

4. Clean and rebuild the cache

yum clean all
yum makecache

5. Enable automatic mounting at boot

echo "/dev/cdrom  /mnt/cdrom  iso9660  defaults 0 0" >> /etc/fstab

DNF Overview and Usage

DNF (Dandified Yum) is the next‑generation RPM package manager, using RPM, libsolv and hawkey libraries. It became the default in Fedora 22 and RHEL 8, offering better performance, modular content support, and a stable API while remaining compatible with yum commands.

Common DNF commands

# List all RPM packages
DNF list

# Install a package
DNF install wget

# Remove a package
DNF remove wget

# List package groups
DNF grouplist

# Install a group
DNF groupinstall 'Security Tools'

# Show enabled repositories
DNF repolist

# Show all repositories
DNF repolist all

# List installed packages
DNF list installed

# Search for a package
DNF search wget

# Show package info
DNF info wget

# Clean cache
DNF clean all

# Show command help
DNF help clean

# View command history
DNF history

# Install from a specific repo
DNF --enablerepo=epel install nginx

# Reinstall a package
DNF reinstall wget
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxpackage managementCentOS8dnfyumlocal repository
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.