Discover how to setup local Yum repository in RHEL 7 using an ISO file with our detailed guide. Step-by-step instructions and tips for efficient package management and system updates. #centlinux #linux #yum
Table of Contents
Problem Statement
rpm command serves its purpose while installing individual packages, but it will become too difficult to install packages with hierarchical dependencies. At this point we can take advantage from yum command. Unfortunately, there is no yum repository configured in RHEL 7 servers by default, and to access to public yum repositories from Red Hat Network (RHN) you are required to have an Active Red Hat Subscription. However, we can utilize the contents of RHEL 7 ISO file to create a Local Yum Repository for our network.

Setup Local Yum Repository in RHEL 7
Transfer the RHEL 7 ISO on the Server where we want to configure Local Yum Repository. I have already copied RHEL 7 ISO on the Server.
ls rhel*Output:
rhel-server-7.0-x86_64-dvd.iso
Create a directory and mount the ISO file on that directory.
mkdir /mnt/iso
echo "/root/rhel-server-7.0-x86_64-dvd.iso /mnt/iso iso9660 defaults 0 0" >> /etc/fstab
mount -aOutput:
mount: /dev/loop0 is write-protected, mounting read-only
Now, RHEL 7 ISO has been persistently mounted at /mnt/iso. Let’s add Local Yum Repository now.
cat >> /etc/yum.repos.d/localyum.repo << EOF
[localyum]
name=localyum
baseurl=file:///mnt/iso
enabled=1
gpgcheck=0
EOFBuild cache of our yum server.
yum clean all
yum makecacheOutput:
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
localyum | 4.1 kB 00:00:00
(1/4): localyum/group_gz | 134 kB 00:00:01
(2/4): localyum/filelists_db | 3.0 MB 00:00:02
(3/4): localyum/primary_db | 3.4 MB 00:00:01
(4/4): localyum/other_db | 1.3 MB 00:00:00
Metadata Cache Created
Our Local yum repository has been configured successfully. Since, we want to use this Local yum repository for other servers as well, therefore, we use an FTP Server to share this repository to other servers in network.
Install FTP on RHEL 7
Install an FTP Server using newly configured yum repository.
yum install -y vsftpdStart and enable vsftpd service.
systemctl start vsftpd.service
systemctl enable vsftpd.serviceAllow FTP service through Linux firewall.
firewall-cmd --permanent --add-service=ftp
firewall-cmd --reloadNow create a directory in /var/ftp/pub and change the mountpoint of ISO in /etc/fstab.
cd /var/ftp/pub/
mkdir iso
sed -i 's//mnt/iso//var/ftp/pub/iso/g' /etc/fstab
umount /mnt/iso
mount -aOutput:
mount: /dev/loop0 is write-protected, mounting read-only
Change SELinux mode to permissive.
sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/sysconfig/selinux
setenforce permissiveConfigure Yum Clients
Now connect to another server and configure its yum repository.
cat >> /etc/yum.repos.d/localyum.repo << EOF
[localyum]
name=localyum
baseurl=ftp://192.168.116.11/pub/iso
enabled=1
gpgcheck=0
EOFRebuild yum cache.
yum clean all
yum makecacheOutput:
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
localyum | 4.1 kB 00:00:00
(1/4): localyum/group_gz | 134 kB 00:00:00
(2/4): localyum/filelists_db | 3.0 MB 00:00:00
(3/4): localyum/primary_db | 3.4 MB 00:00:00
(4/4): localyum/other_db | 1.3 MB 00:00:00
Metadata Cache Created
We can now configure all RHEL 7 servers in our network to use this Local Yum Repository.
Boost your Linux skills with the “Linux Command Line Basics” by Ahmed Alkabary—a perfect course for beginners who want to master the command line efficiently. Whether you’re aiming for a career in system administration, DevOps, or just want to manage your Linux systems like a pro, this course covers everything from essential commands to practical exercises.
Start learning at your own pace and transform the way you interact with Linux today. [Enroll here] to get started instantly!
Disclaimer: This post contains affiliate links. If you purchase through these links, I may earn a small commission at no extra cost to you. Your support helps me continue sharing helpful tech content.
Final Thoughts
Setting up a local Yum repository in RHEL 7 using an ISO file is a smart way to streamline package management and enhance system efficiency. By following this guide, you should now have a reliable local repository that accelerates software installation and updates.
Need expert AWS and Linux system administration? From cloud architecture to server optimization, I provide reliable and efficient solutions tailored to your needs. Hire me today!
Simplify package management with your local Yum repository today!

Leave a Reply
Please log in to post a comment.