在离线环境下配置CentOS

建立离线环境 目录

基础操作系统/应用流

安装BaseOS/AppStream包的方法。

找茬

挂载安装介质。

$ sudo mount CentOS-8.2.2004-x86_64-dvd1.iso /media
$ sudo ls -l /media/
$ sudo cp -v /media/media.repo /etc/yum.repos.d/centos8.repo
$ sudo chmod 644 /etc/yum.repos.d/centos8.repo
$ sudo ls -l /etc/yum.repos.d/centos8.repo

设置仓库

在`/etc/yum.repos.d/centos8.repo`中设置仓库。

修改之前

[InstallMedia]
name=CentOS Linux 8
mediaid=None
metadata_expire=-1
gpgcheck=0
cost=500

修改后

[Local-BaseOS]
name=CentOS-8 - Local - BaseOS
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///media/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[Local-AppStream]
name=CentOS-8 - Local - AppStream
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///media/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

确定

$ sudo dnf clean all
$ sudo dnf repolist
Failed to set locale, defaulting to C
CentOS-8 - AppStream                                                                                                                      0.0  B/s |   0  B     00:01    
CentOS-8 - Base                                                                                                                           0.0  B/s |   0  B     00:01    
CentOS-8 - Extras                                                                                                                         0.0  B/s |   0  B     00:01    
CentOS Linux 8 - AppStream                                                                                                                 34 MB/s | 5.7 MB     00:00    
CentOS Linux 8 - BaseOS                                                                                                                    60 MB/s | 2.2 MB     00:00    
Failed to synchronize cache for repo 'AppStream', ignoring this repo.
Failed to synchronize cache for repo 'BaseOS', ignoring this repo.
Failed to synchronize cache for repo 'extras', ignoring this repo.
Last metadata expiration check: 0:00:01 ago on Mon Sep 14 14:48:23 2020.
repo id                                                                         repo name                                                                           status
InstallMedia-AppStream                                                          CentOS Linux 8 - AppStream                                                          4901
InstallMedia-BaseOS                                                             CentOS Linux 8 - BaseOS                                                             1672

额外软件包库 (EPEL)

安装EPEL包的方法。

下载

只需执行以下命令,次数与您想要下载的帖子数量相同。

wget -c -r -N --no-parent https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/

如果在在线环境下使用CentOS,使用reposync比使用wget更方便。

另外,数据容量大约为20GB左右。

设置存储库

将存储库设置在/etc/yum.repos.d/epel8.repo。

[Local-EPEL]
name=CentOS-8 - Local - EPEL
metadata_expire=-1
gpgcheck=0
enabled=1
baseurl=file:///mnt/host/epel/dl.fedoraproject.org/pub/epel/8/Everything/x86_64
# gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

确认

$ sudo dnf clean all
$ sudo dnf repolist
广告
将在 10 秒后关闭
bannerAds