1)开机,挂载光驱文件,将光驱文件挂载到opt下。这里我是先创建了一个/opt/centos目录并使用SecureFX将镜像上传到该目录下。
[root@compute ~]# mkdir /opt/centos
镜像上传成功后使用命令将镜像挂载到/opt/centos下,并设置开机自动挂载到相应目录。进入/etc/fstab并添加最后一行代码
[root@compute ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Aug 3 18:39:24 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=75ae9b9a-1874-4c64-9c35-6ceb82730f63 /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/opt/CentOS-7-x86_64-DVD-1511.iso /opt/centos/ iso9660 defaults 0 0
2)配置本地yum源。
[root@compute ~]# vi /etc/yum.repos.d/yum.repo
[centos]
name=centos
baseurl=file:///opt/centos
enabled=1
gpgcheck=0
[root@compute ~]# yum clean all& yum makecache
3)测试下载vim,成功即本地yum源已配置好。
来源:oschina
链接:https://my.oschina.net/u/4358286/blog/4318424