Linux搭建本地源、网络源

CentOS 7 搭建本地源

mkdir /mnt/cdrom
rm -rf /etc/yum.repos.d/*

# 编辑repo配置文件
vi /etc/yum.repos.d/centos.repo
[Packages]
name = packages
baseurl = file:///mnt/cdrom
enabled = 1
gpgcheck = 0

# 开机自动挂载
vi /etc/fstab
/dev/sr0  /mnt/cdrom  iso9660    defaults  0  0

mount -a

yum clean all  # 清除yum缓存
yum makecache  # 建立yum缓存
yum repolist   

CentOS 8 搭建本地源

# 修改repo配置文件
vi /etc/yum.repos.d/centos.repo
[AppStream]
name = AppStream
baseurl = file:///mnt/cdrom/appstream
enabled = 1
gpgcheck = 0
[BaseOS]
name = BaseOS
baseurl = file:///mnt/cdrom/baseos
enabled = 1
gpgcheck = 0

搭建网络源

部署阿里yum源

# Centos 7
wget -O /etc/yum.repos.d/Centos-7.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# Centos 8
wget -O /etc/yum.repos.d/Centos-8.repo https://mirrors.aliyun.com/repo/Centos-8.repo

# 生成缓存
yum makecache
posted @ 2022-09-05 01:35  未来的你!  阅读(99)  评论(0)    收藏  举报