Configure YUM repository using DVD or CD ROM CentOS / RHEL
YUM is the package management tool that helps to install or update the package through the network or local, the same time it provides an easy method to install a package with its dependent packages.
Configuration files are under /etc
directory, /etc/yum.conf
is the mail global file that contains the global options such as cache directory, computer log directory, etc… To add new or update the existing repository, you need to go the /etc/repos.d
directory and create or open a file that ends on .repo
respectively.
This document is applicable to both CentOS version, 7 and 6.
Create Source
Before creating new repository file, you must know the repository source ( where the packages stored locally or remotely). The repository sources can be created either using a createrepo
package or mounting the DVD on the directory. Mounting the DVD/CD ROM will lead to saving the space on HDD used by being copied to HDD.
Create a directory to mount CD/DVD ROM. For Example.
mkdir /cdrom
Mount the CD/DVD ROM on any directory of your wish, for testing, mount it on /cdrom
.
mount /dev/cdrom /cdrom
Configuration file
Before creating a new repo configuration file, I request you to move the default OS repository files to some other directory or remove the unwanted repository file.
Create the new repo file called cdrom.repo under /etc/yum.repos.d
directory.
vi /etc/yum.repos.d/cdrom.repo
Add the following details.
[cdrom] name=CDROM Repo baseurl=file:///cdrom enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Where,
Package Installation
Install any package using the yum
command. For example, let us install the VsFTPD package using the YUM
.
yum install vsftpd
Output:
Loaded plugins: fastestmirror
cdrom | 3.6 kB 00:00:00
(1/2): cdrom/group_gz | 156 kB 00:00:00
(2/2): cdrom/primary_db | 3.1 MB 00:00:00
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-22.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================
Package Arch Version Repository Size
===============================================================================================================
Installing:
vsftpd x86_64 3.0.2-22.el7 cdrom 169 k
Transaction Summary
===============================================================================================================
Install 1 Package
Total download size: 169 k
Installed size: 348 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : vsftpd-3.0.2-22.el7.x86_64 1/1
Verifying : vsftpd-3.0.2-22.el7.x86_64 1/1
Installed:
vsftpd.x86_64 0:3.0.2-22.el7
Complete!
That’s all. You have successfully configured the local repository on the machine. But, it is limited to the single machine where the CD or DVD is mounted.