CentOS / RHEL 7 : How to setup yum repository using locally mounted DVD
1. Mount the RHEL 7 installation media ISO to some directory. For example /mnt :
# mount -o loop rhel7.iso /mnt
2. Copy the media.repo file from the mounted directory /mnt /etc/yum.repos.d/ and name it as rhel7.repo.
# cp /mnt/media.repo /etc/yum.repos.d/rhel7.repo
3. Give appropriate permissions to the repository file.
# chmod 644 /etc/yum.repos.d/rhel7.repo
4. Modify the repo file and change the parameter gpgcheck=0 to gpgcheck=1 and add below 3 lines to the same file.
enabled=1 baseurl=file:///mnt/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
5. Once you have done all the changes, the final repo file shiould look like below.( Note that – media-id may be different depending on the version of RHEL for which DVD is used)
[InstallMedia] name=DVD for Red Hat Enterprise Linux 7.3 Server mediaid=9859238196.834790 metadata_expire=-1 gpgcheck=1 cost=500 enabled=1 baseurl=file:///mnt/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
6. Make sure you clear the related caches by yum clean all and subscription-manager clean once.
# yum clean all # subscription-manager clean
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步