web analytics

Create local yum repo in Centos7

To create a local yum repo, all you need to do is to make sure the packages are available in a path in the server, say /downloaded_packages/

Now, create a repo file. Be default, all repo files are present in the path /etc/yum.repos.d/ . I am going to name my repo as local_yum, so I will create a repo file named local_yum.repo and add the following contents in it.

cat /etc/yum.repos.d/local_yum.repo

[local_yum]
name=local_yum
baseurl=file:///downloaded_packages/
gpgcheck=0
enabled=1

The above files tells the programme to take the packages from the baseurl mentioned in the file, which in our case is our local folder /downloaded_packages/

 

Now check if our repo is listed correctly. In my case, I have not set any other repos, so only my local repo is listed. If you have other repos, you will find more repos along with the one we created.

root@abc]# yum repolist
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
local_yum | 2.9 kB 00:00:00
local_yum/primary_db | 57 kB 00:00:00
repo id repo name status
local_yum local_yum 55
repolist: 55

Now, let us install wget package from our local_yum repo.

root@abc]# yum install wget
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
Resolving Dependencies
–> Running transaction check
—> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
wget x86_64 1.14-18.el7_6.1 local_yum 547 k

Transaction Summary
========================================================================================
Install 1 Package

Total download size: 547 k
Installed size: 2.0 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wget-1.14-18.el7_6.1.x86_64 1/1
install-info: No such file or directory for /usr/share/info/wget.info.gz
Verifying : wget-1.14-18.el7_6.1.x86_64 1/1

Installed:
wget.x86_64 0:1.14-18.el7_6.1

Complete!

Since there is only one repo present in my case, my default the package will be installed from my local_yum repo that we just created. In your case, if more repos are present, then you will have to choose the repo while installing the package, to confirm it’s working correctly.

root@abc]# yum –enablerepo=local_yum install wget

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>