How to create a local repository using a ISO in CentOS 7

Dear friend, Today we will see how to create a local repository using a ISO in CentOS 7. I will see you step by step commands and process, so that you can easily create a local repository in your server when you need it.

As you know some time we don’t have internet connection and we need to up-grade some packages or we need to install some packages then we can create a local repository using ISO image and we can install and up-grade package using yum tool.

In this tutorial we will cover this below topics: –

How to mount ISO image on CentOS 7?

How to create repository file?

How to clean repository list?

How to check repository list?

How to install packages with yum tool using local repository?

So let’s start step by step process to create local repository in CentOS 7.

First all we need to be copy our ISO image on our server. You can see here I have copied my ISO image on home directory.

[root@urclouds ~]# pwd /root [root@urclouds ~]# ls -l total 4556820 -rw-r--r--. 1 root root        355 May  5 12:41 1 -rw-------. 1 root root       1225 Apr  9 14:15 anaconda-ks.cfg -rw-r--r--. 1 root root 4470079488 Jan 22 18:10 CentOS-7-x86_64-DVD-1804.iso [root@urclouds ~]# 

How to mount ISO image on CentOS 7?

Now we need to be mount this ISO in /mnt directory. We can use below command to mount this ISO file.

[root@urclouds ~]# mount -o loop CentOS-7-x86_64-DVD-1804.iso /mnt
mount: /dev/loop0 is write-protected, mounting read-only
[root@urclouds ~]#

We can check our /mnt drive is mounted our not using df -h like below: –

[root@urclouds ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        45G  6.1G   39G  14% /
devtmpfs        2.9G     0  2.9G   0% /dev
tmpfs           2.9G     0  2.9G   0% /dev/shm
tmpfs           2.9G  8.6M  2.9G   1% /run
tmpfs           2.9G     0  2.9G   0% /sys/fs/cgroup
/dev/sda1       497M  118M  379M  24% /boot
tmpfs           581M     0  581M   0% /run/user/0
/dev/loop0      4.2G  4.2G     0 100% /mnt
[root@urclouds ~]#

You can see in above our /mnt drive has been successfully mounted.

How to create repository file?

Now we need to be create repository file. We can go to /etc/yum.repos.d/ directory and create a centos7.repo with this content. Like below:-

[root@urclouds ~]# cat /etc/yum.repos.d/centos7.repo
[CentOS7]
name=CentOS7
baseurl=file:///mnt
enabled=1
gpgcheck=0
[root@urclouds ~]#

How to clean repository list?

After the file creation we need to be clean our repository list using below command.

[root@urclouds ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: CentOS7 base epel extras remi-php73 remi-safe updates
Cleaning up list of fastest mirrors
[root@urclouds ~]#

How to check repository list?

Now we can check our repository list using below command:-

[root@urclouds ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base: centos.mirror.ate.info
epel: epel.besthosting.ua
extras: centos.mirror.fr.planethoster.net
remi-php73: fr2.rpmfind.net
remi-safe: ap.stykers.moe
updates: centos.crazyfrogs.org
repo id                                 repo name                                                                             status
CentOS7                                               CentOS7                                                                                3,971
base/7/x86_64                           CentOS-7 - Base                                                                       10,019
*epel/x86_64                            Extra Packages for Enterprise Linux 7 - x86_64                                        13,216
extras/7/x86_64                         CentOS-7 - Extras                                                                        409
remi-php73                              Remi's PHP 7.3 RPM repository for Enterprise Linux 7 - x86_64                            312
remi-safe                               Safe Remi's RPM repository for Enterprise Linux 7 - x86_64                             3,343
updates/7/x86_64                        CentOS-7 - Updates                                                                     1,982
repolist: 33,252
[root@urclouds ~]#

How to install packages with yum tool using local repository?

Now we can install packages using our local repository like below:-

[root@urclouds ~]# yum install ntp
Loaded plugins: fastestmirror
CentOS7                                                                                                      | 3.6 kB  00:00:00
Loading mirror speeds from cached hostfile
base: centos.mirror.ate.info
epel: epel.besthosting.ua
extras: centos.mirror.fr.planethoster.net
remi-php73: fr2.rpmfind.net
remi-safe: ap.stykers.moe
updates: centos.crazyfrogs.org
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.6p5-28.el7.centos will be installed
--> Processing Dependency: ntpdate = 4.2.6p5-28.el7.centos for package: ntp-4.2.6p5-28.el7.centos.x86_64
--> Processing Dependency: libopts.so.25()(64bit) for package: ntp-4.2.6p5-28.el7.centos.x86_64
--> Running transaction check
---> Package autogen-libopts.x86_64 0:5.18-5.el7 will be installed
---> Package ntpdate.x86_64 0:4.2.6p5-28.el7.centos will be installed
--> Finished Dependency Resolution 
Dependencies Resolved
 ====================================================================================================================================
Package                           Arch                     Version                                 Repository                 Size
Installing:
ntp                               x86_64                   4.2.6p5-28.el7.centos                   CentOS7                   549 k
Installing for dependencies:
autogen-libopts                   x86_64                   5.18-5.el7                              CentOS7                    66 k
ntpdate                           x86_64                   4.2.6p5-28.el7.centos                   CentOS7                    86 k
Transaction Summary
Install  1 Package (+2 Dependent packages)
Total download size: 701 k
Installed size: 1.6 M
Is this ok [y/d/N]: y
Downloading packages:
Total                                                                                                32 MB/s | 701 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : autogen-libopts-5.18-5.el7.x86_64                                                                                1/3
Installing : ntpdate-4.2.6p5-28.el7.centos.x86_64                                                                             2/3
Installing : ntp-4.2.6p5-28.el7.centos.x86_64                                                                                 3/3
Verifying  : ntpdate-4.2.6p5-28.el7.centos.x86_64                                                                             1/3
Verifying  : autogen-libopts-5.18-5.el7.x86_64                                                                                2/3
Verifying  : ntp-4.2.6p5-28.el7.centos.x86_64                                                                                 3/3
Installed:
ntp.x86_64 0:4.2.6p5-28.el7.centos
Dependency Installed:
autogen-libopts.x86_64 0:5.18-5.el7                             ntpdate.x86_64 0:4.2.6p5-28.el7.centos
Complete!
[root@urclouds ~]#

That’s all we have successfully created local repository using ISO image in CentSO 7 server.

You can also see this below link, how to configure NTP server and NTP client on CentOS 7

This Post Has 10 Comments

  1. gel nails breda

    This text is priceless. How can I find out more?

  2. oprolevorter

    Everything is very open and very clear explanation of issues. was truly information. Your website is very useful. Thanks for sharing.

  3. Janette

    Appreciate this post. Let me try it out.

  4. JarrodVat

    I enjoy what you guys are usually up too. This kind of clever work and reporting!

  5. Britt

    Magnificent beat ! I wish to apprentice while you amend your website, how could i subscribe for a blog website?
    The account aided me a acceptable deal. I had been a little bit acquainted
    of this your broadcast offered bright clear concept

    1. Zafar

      Hi Britt,

      You can subscribe my blog website to click on below subscription button.

      Thanks & Regards
      Zafar

  6. Danielle

    I think that what you composed was actually very
    logical. But, what about this? what if you added a little
    information? I ain’t suggesting your information is
    not solid., but what if you added a post title to possibly grab a person’s attention? I mean How to create a local repository using a ISO in CentOS
    7 – UrClouds is kinda boring. You should look at Yahoo’s front page and see how they create news headlines
    to get viewers to click. You might try adding a video or
    a related pic or two to grab people excited about what you’ve written. Just my opinion, it might make your blog a little
    bit more interesting.

    1. Zafar

      Hi Danielle,

      Thanks lot for your suggestion, I will try to do it.

      Thanks & Regards
      Zafar

  7. فروش بک لینک دائمی

    Great beat ! I wish to apprentice whilst you amend your site, how could i subscribe for a blog site?

    The account helped me a appropriate deal. I have been a little bit familiar
    of this your broadcast offered brilliant transparent concept

  8. SUPERSLOT

    Really informative post.Really thank you! Awesome.

Leave a Reply