Linux 配置单机yum源--ISO镜像做源

前提:防火墙关闭、SElinus关闭

1、上传ISO镜像(建议传到home目录下)

[root@localhost home]# ls iso/
CentOS-7.4-x86_64-DVD-1708.iso

2、挂载目录

[root@localhost home]# mount /home/iso/CentOS-7.4-x86_64-DVD-1708.iso /mnt/
mount: /dev/loop2 写保护,将以只读方式挂载

3、修改配置文件

   3.1 进入目录并备份原始配置文件

[root@localhost opt]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv CentOS-* bak/

 3.2 创建yum的repo文件

[root@localhost yum.repos.d]# vi yum.repo 
[centos]         
name=centos-danji 
enabled=1     
gpgcheck=0      
baseurl=file:///mnt    

4、查看yum配置是否生效

[root@localhost yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识                                                                                                    源名称                                                                                                           状态
centos                                                                                                    centos-danji                                                                                                     3,894
repolist: 3,894

5、结束

猜你喜欢

转载自www.cnblogs.com/wangzy-tongq/p/11251734.html