Linux的本地yum源配置

注:本次测试机器为centos8

centos8:

1.创建目录

mkdir /mnt/cdrom

2.挂载

2.1进入/etc/yum.repos.d目录

cd /etc/yum.repos.d/ //加入yum.repos.d目录

2.2创建一个目录,把原有的repo文件移进去

mkdir /mnt/cdrom

mv * /mnt/repo

2.3创建新的repo文件

[root@localhost yum.repos.d]# vim base.repo

输入以下示例:

[base]

name=base

baseurl=file:///mnt/cdrom

enabled=1

gpgcheck=0

2.4用mount命令进行挂载

[root@localhost ~]# mount /dev/cdrom /mnt/cdrom
mount: /dev/sr0 is write-protected, mounting read-only

2.5测试:清除yum仓库缓存

[root@localhost ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base
Cleaning up everything

2.6创建yum仓库缓存

[root@localhost ~]# yum makecache
已加载插件:fastestmirror
base                                              | 3.6 kB  00:00:00
(1/4): base/group_gz                              | 155 kB  00:00:00
(2/4): base/primary_db                            | 2.8 MB  00:00:00
(3/4): base/filelists_db                          | 2.9 MB  00:00:00
(4/4): base/other_db                              | 1.2 MB  00:00:00
Determining fastest mirrors