#开启自动挂载服务
systemctl start autofs
#设置开机自动挂载
systemctl enable autofs
#路径/misc/cd "包含repodata"文件夹为仓库路径
#yum配置文件/etc/yum.conf
#备份系统源
mkdir bak;mv /etc/yum.repos.d/bak
#创建源文件 必须以.repo结尾
vim /etc/yum.repos.d/base.repo
[base]
name=cdrom base
baseurl=file:///misc/cd
#开启校验
gpgcheck=1
#导入密钥
gpgkey=file:///misc/cd/RPM-GPG-KEY-CentOS-7 #校验文件
[epel]
name=aliyun epel
baseurl=http://mirrors.aliyun.com/epel/$releasever/$basearch/
gpgcheck=0
#enable=1 启用;0禁用
enable=1
#查看仓库列表
[20:08:38 root@centos7 yum.repos.d]#yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
base cdrom base 10,097
epel/7/x86_64 aliyun epel 13,524
repolist: 23,621
#成功
清除缓存 yum clean
默认缓存位置 /var/cache/yum/
来源:https://www.cnblogs.com/franc/p/12300649.html