Need to set up yum repository for locally-mounted DVD on Red Hat Enterprise Linux 7

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7

Issue

  • How to set up yum repository to use locally-mounted DVD with Red Hat Enterprise Linux (RHEL) 7
  • Would like to upgrade server from RHEL 7.x to RHEL 7.y
  • Have a secure environment that will never be connected to the internet, but still needs to be updated
  • Way to update the packages on server, with no satellite server and servers disconnected from internet
  • Offline patches for Red Hat systems
  • How do I create a local repository in RHEL 7?

Resolution

  • Once you have downloaded a DVD version of your chosen Rhel Version and copied it over to a location on your server.
  • Mount the RHEL installation ISO to a directory like /mnt/disc, e.g.:

    # mkdir -p  /mnt/disc
    # mount -o loop RHEL7.1.iso /mnt/disc
    

    If you use DVD media , you can mount like below.

    # mkdir -p  /mnt/disc
    # mount /dev/sr0  /mnt/disc
    
  • Copy the media.repo file from the root of the mounted directory to /etc/yum.repos.d/ and set the permissions to 0644 or another similar permissions set:

    # cp /mnt/disc/media.repo /etc/yum.repos.d/rhel7dvd.repo
    # chmod 644 /etc/yum.repos.d/rhel7dvd.repo
    
  • Edit the new repo file, changing the gpgcheck=0 setting to 1 and adding the following 3 lines

    vi /etc/yum.repos.d/rhel7dvd.repo
    enabled=1
    baseurl=file:///mnt/disc/
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    

    In the end, the new repo file could look like the following

    [InstallMedia]
    name=DVD for Red Hat Enterprise Linux 7.1 Server
    mediaid=1359576196.686790
    metadata_expire=-1
    gpgcheck=1
    cost=500
    enabled=1
    baseurl=file:///mnt/disc/
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    
  • Clear the cache and check whether you can get the packages list from the DVD repo

    # yum clean all
    # yum repolist enabled
  • It should look like the following if no other repository is enabled.
    To avoid any corruption its recommend to disable any non-redhat repositories.
# yum repolist enabled
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id                                                                                 repo name                                                                     
InstallMedia                                                                        Red Hat Enterprise Linux 7.7 
repolist: 5,229
  • If no errors are returned, the following can be used to update:

    # yum update
    

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

27 Comments

waste documemt

Its not a waste document, it works fine .

This help too much.

Excellent My Friend !!!

This was very useful! Thanks

That's Great! Thank you

Outstanding!..Thanks a bunch.

Got lost at step 1. Where do I get "installation .iso ?"

For RHEL 7 Server you want the "Red Hat Enterprise Linux 7.6 Binary DVD" located on the 7.6 Downloads page.

If you need a different version or variant (Such as workstation) change the drop down near the top of the page to the correct version. What you're looking for is the Binary DVD that contains the packages.

Didn't fix the issue that I had,

Perfect!! Works great!!

When I run yum --noplugins list, I am receiving this error: file:///mnt/repodata/repomd.xml.asc: [Errno 14] curl#37 - "Couldn't open file /mnt/repodata/repomd.xml.asc" There is a file named "repomd.xml" in that directory, but I can't rename it as that directory is mounted read-only. Any suggestions? Thanks.

That is caused by the repo_gpgcheck variable you have in /etc/yum.conf. It's telling yum to look for an additional security check which we currently do not provide in our repositories.

On RHEL client, yum update fails with error "[Errno 14] HTTPS Error 404 - Not Found", yum was unable to download "repomd.xml.asc" file.

That fixed it. Thanks!

Not followed step by step but it helped me to setup local repo as we were disconnected from the network. Thanks guys!

after creating local repo and cleaning with subscription command while updating with yum below error shown,
# yum update Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager, versionlock This system is not registered with an entitlement server. You can use subscription-manager to register. No packages marked for update kindly suggest. reg. mak

Same issue here also.

I got the same issue

The Binary DVD only contains 1 version of the packages from the base repo (example: rhel-7-server-rpms) at the time of release. If you install a RHEL 7.6 machine, the 7.6 Binary DVD will not update this system. The only DVD that would is a higher version such as RHEL 7.7.

I’m using 7.6 So I need to have 7.7 right?

Yes. You could also register the system, or using another online system, sync the repositories you require.

How can we regularly update a disconnected system (A system without internet connection)?

This solution works to access the ISO image. When I run "yum update," towards the end of the package identification process, the following error is thrown, before terminating without updating:

. . . ---> Package redhat-release.x86_64 0:8.0-0.44.el8 will be obsoleting ---> Package redhat-release-server.x86_64 0:7.6-4.el7 will be obsoleted ---> Package redhat-rpm-config.noarch 0:9.1.0-87.el7 will be updated ---> Package redhat-rpm-config.noarch 0:116-1.el8 will be an update Error: Invalid version flag: if

TIA, Barry

Hello,

It looks like you have configured a RHEL 8 repository on a RHEL 7 server which is not a supported configuration.

`redhat-release.x86_64 0:8.0-0.44.el8 will be obsoleting ---> Package redhat-release-server.x86_64 0:7.6-4.el7`

For upgrading RHEL 7 to RHEL 8, the steps are defined here

John, This worked.

Thank you.