RHEL7: Create a local repository.

Share this link

Prerequisites

Download an iso image of CentOS 7 available at the CentOS website.

You need to choose between a minimal image, a liveCD image, a DVD image or an Everything image.

To build a local repository, don’t choose the minimal or the liveCD images, prefer the DVD (4GB) or the Everything images (7GB).

Configuration Procedure

Create a directory for the CentOS 7 distribution:

# mkdir -p /var/www/html/centos7

Note: By creating the local repository in the /var/www/html directory, you will be ready to make it available on the network after installing an Apache webserver at a later stage.

Mount the previously downloaded Centos 7 distribution  (called here CentOS-7.0-1406-x86_64-DVD.iso) and copy it locally:

# mount -o loop CentOS-7.0-1406-x86_64-DVD.iso /mnt
# cd /mnt
# tar cvf - . | (cd /var/www/html/centos7; tar xvf -)
# cd /; umount /mnt

Go to the directory where the repository configuration is:

# cd /etc/yum.repos.d

Create the centos7.repo file and type:

[centos7]
name=centos7
baseurl=file:///var/www/html/centos7/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Clean up the yum configuration and check it:

# yum clean all
# yum repolist all

If you regularly add new packages in your local repository, don’t forget to update it. To do that, install the createrepo package and execute it with the repository path as argument:

# yum install -y createrepo
# createrepo /var/www/html/centos7
# yum clean all
# yum repolist all
1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 3.33 out of 5)
Loading...
8 comments on “RHEL7: Create a local repository.
  1. miguel says:

    Hi Certdepot, in the exam, is it okay to use FTP service instead of HTTPD for the local repo setup?

    • CertDepot says:

      Yes, it should be fine.

      • scruff says:

        Hi there,
        Why shouldn’t we use ftpd or httpd at the exam? Let me suppose that the DVD-ISO will not be directly attached to the LAB virtual PC and we should obtain the RPMS’s from remote ftp or http server? Hope for your answer.

        • CertDepot says:

          You have to be ready to mount a DVD-ISO or use a remote repository through httpd. The use of ftpd is less likely.

          • scruff says:

            I noticed, that we will need “createrepo” utility to make local repository. It this utility will be installed by default or should we install it via rpm command?

          • CertDepot says:

            The createrepo package is rarely installed by default. You will need to install it only if you have to build new metadata associated with the repository (in the case of a Dvd, no metadata needs to be built).

  2. davrokh says:

    Just a small note your command # cd /etc/yum.repo.d should be # cd /etc/yum.repos.d

Leave a Reply

Upcoming Events (Local Time)

There are no events.

RHCSA7: Task of the day

Allowed time: 5 minutes.
Create a new user account called "bob" with password "redhat" and set expiration in one week.

RHCE7: Task of the day

Allowed time: 10 minutes.
Configure a httpd server that executes a Perl script in the /var/www/cgi-bin directory displaying "Hello!".

Follow me on Twitter

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...