Thursday, November 23, 2017

How to setup yum repository for locally-mounted DVD on Red Hat Enterprise Linux 7

Mount the RHEL 7 installation ISO to a directory like /mnt, e.g.:

# mount -o loop RHEL7.1.iso /mnt

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

# mount -o loop /dev/sr0  /mnt

Copy the media.repo file from the root of the mounted directory to /etc/yum.repos.d/ and set the permissions to something sane, e.g.:

# cp /mnt/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

enabled=1
baseurl=file:///mnt/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

In the end, the new repo file could look like the following (though the mediaid will be different depending on the version of RHEL):

[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/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

clear the related caches by yum clean all and subscription-manager clean once

# yum clean all
# subscription-manager clean

check whether you can get the packages list from the DVD repo

# yum  --noplugins list

if no problem , you wil update

# yum  --noplugins update

No comments:

Post a Comment