1、在/mnt下新建cdrom目录(createrepo /mnt 时要求目录可写)
[root@host-172-30-122-68 yum.repos.d]# mkdir /mnt/cdrom
2、修改文件
vi /etc/yum.repos.d/CentOS7-ISO.repo
内容如下:
[cdrom]
name=Local cdrom
baseurl=file:///mnt/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
yum clean all
[root@host-172-30-122-68 yum.repos.d]# createrepo /mnt
Spawning worker 0 with 894 pkgs
Spawning worker 1 with 894 pkgs
Spawning worker 2 with 894 pkgs
Spawning worker 3 with 894 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@host-172-30-122-68 yum.repos.d]#
来源:oschina
链接:https://my.oschina.net/u/4353184/blog/4293807