# 挂载
[root@localhost ~]# mount /dev/sr0 /mnt
# 创建 centos 目录
[root@localhost ~]# mkdir /opt/centos
# 将挂载内容复制到 centos 目录下
[root@localhost ~]# cp -rfv /mnt/* /opt/centos
# 创建 yum 备份目录
[root@localhost ~]# mkdir /opt/yum
# 备份
[root@localhost ~]# mv /etc/yum.repos.d/* /opt/yum
# 创建配置文件,文件名自定义
[root@localhost ~]# touch /etc/yum.repos.d/loccal.repo
# 编辑 local.repo 文件内容
[root@localhost ~]# vi /etc/yum.repos.d/loccal.repo
# 写入内容
[local]
name="yum 本地源"
baseurl=file:///opt/centos
enabled=1
gpgcheck=0
# 清除 YUM 原有缓存
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: local
# 生成新的 YUM 缓存
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
local
| 3.6 kB 00:00:00
(1/2): local/group_gz
| 153 kB 00:00:00
(2/2): local/primary_db
| 3.3 MB 00:00:00
repo id repo name
status
local "yum 本地源"
4,070
repolist: 4,070