mkdir -p /media/centos7/
mount /dev/cdrom /media/centos7
cp -rf /etc/yum.repos.d /etc/yum.repos.d_$(date '+%Y%m%d_%H%M%S')
rm -rf /etc/yum.repos.d/*
vi /etc/yum.repos.d/Media.repo
[iso] name=Media baseurl=file:///media/centos7/ gpgcheck=0 enabled=1
# 清除yum缓存 yum clean all # 缓存本地yum源 yum makecache # 测试yum本地源 yum list
注:借鉴大佬文章(24条消息) CentOS7配置本地yum源(超详细过程)_KingveyLee的博客-CSDN博客_centos7配置本地yum源