CentOS7.9搭建局域网yum源

一、搭建本地yum源
1、将系统镜像复制到空间较大的目录
[root@localhost ~]# mv CentOS-7.9-x86_64-DVD-2009.iso /home/
2、创建挂载目录并挂载系统镜像
[root@localhost ~]# cd /home
[root@localhost home]# mkdir /mnt/iso
[root@localhost home]# mount -o loop CentOS-7.9-x86_64-DVD-2009.iso /mnt/iso
mount: /dev/loop0 写保护,将以只读方式挂载
[root@localhost home]# ls /mnt/iso
CentOS_BuildTag  EFI  EULA  GPL  images  isolinux  LiveOS  Packages  repodata  RPM-GPG-KEY-CentOS-7  RPM-GPG-KEY-CentOS-Testing-7  TRANS.TBL
3、备份原有的yum源信息并修改配置本地yum源信息
[root@localhost home]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir ./bak
[root@localhost yum.repos.d]# mv ./*.repo ./bak/
[root@localhost yum.repos.d]# cp ./bak/CentOS-Media.repo .
[root@localhost yum.repos.d]# vi CentOS-Media.repo

# CentOS-Media.repo
#  This repo can be used with mounted DVD media, verify the mount point for
#  CentOS-7.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c7-media [command]
# or for ONLY the media repo, do this:
#  yum --disablerepo=\* --enablerepo=c7-media [command]
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///mnt/iso        <--此处修改为镜像挂载路径
        file:///media/cdrecorder/
gpgcheck=1
enabled=1        <--此处将

你可能感兴趣的:(linux,centos,服务器)