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.
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/cdrom3. 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=14. Clean and rebuild the cache
yum clean all
yum makecache5. Enable automatic mounting at boot
echo "/dev/cdrom /mnt/cdrom iso9660 defaults 0 0" >> /etc/fstabDNF 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 wgetSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
