您的位置:首页 > 健康 > 美食 > CentOS 8挂载本地源

CentOS 8挂载本地源

2025/2/26 1:00:40 来源:https://blog.csdn.net/qq_40914472/article/details/140887600  浏览:    关键词:CentOS 8挂载本地源

CentOS 8挂载本地源

  • 1.虚拟机连接centos镜像
  • 2.系统查看centos镜像是否在连接上
  • 3. 挂载ISO镜像
  • 4.配置YUM源
    • 1. 备份现有YUM源配置
    • 2. 创建新的YUM源配置文件
    • 3. 清理YUM缓存并重新生成
  • 5.验证YUM源

1.虚拟机连接centos镜像

在这里插入图片描述

2.系统查看centos镜像是否在连接上

[root@localhost ~]# lsblk 
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0   30G  0 disk 
├─sda1        8:1    0  600M  0 part /boot/efi
├─sda2        8:2    0    1G  0 part /boot
└─sda3        8:3    0 28.4G  0 part ├─cl-root 253:0    0 56.4G  0 lvm  /└─cl-swap 253:1    0    2G  0 lvm  [SWAP]
sdb           8:16   0   30G  0 disk 
└─cl-root   253:0    0 56.4G  0 lvm  /
sr0          11:0    1 10.1G  0 rom  #centos镜像

3. 挂载ISO镜像

[root@localhost ~]# mount /dev/sr0 /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
AppStream  BaseOS  EFI  images  isolinux  LICENSE  media.repo  TRANS.TBL

4.配置YUM源

1. 备份现有YUM源配置

为了避免冲突,建议先备份现有的YUM源配置文件。这些文件通常位于/etc/yum.repos.d/目录下:

[root@localhost mnt]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
centos  CentOS-Base.repo
[root@localhost yum.repos.d]# mv CentOS-Base.repo  CentOS-Base.repo.bake

2. 创建新的YUM源配置文件

使用文本编辑器(如vi或vim)创建新的YUM源配置文件。假设你创建的文件名为local.repo:

vi /etc/yum.repos.d/local.repo
#添加以下内容:
[BaseOS]
name=CentOS-$releasever - BaseOS  
baseurl=file:///mnt/BaseOS      
enabled=1  
gpgcheck=0  [AppStream]  
name=CentOS-$releasever - AppStream
baseurl=file:///mnt/AppStream       
enabled=1  
gpgcheck=0

3. 清理YUM缓存并重新生成

[root@localhost yum.repos.d]# yum clean all 
18 文件已删除
[root@localhost yum.repos.d]# yum makecache 
CentOS-8 - BaseOS                                       193 kB/s | 2.6 MB     00:13    
CentOS-8 - AppStream                                    1.5 MB/s | 7.5 MB     00:05    
元数据缓存已建立。
[root@localhost yum.repos.d]# 

5.验证YUM源

[root@localhost yum.repos.d]# yum repolist
仓库 id                                仓库名称
AppStream                              CentOS-8 - AppStream
BaseOS                                 CentOS-8 - BaseOS
[root@localhost yum.repos.d]# yum install nginx -y
上次元数据过期检查:0:01:03 前,执行于 2024年08月02日 星期五 23时27分11秒。
依赖关系解决。
========================================================================================软件包                   架构   版本                                   仓库       大小
========================================================================================
安装:nginx                    x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream 570 k
安装依赖关系:nginx-all-modules        noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  23 knginx-filesystem         noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  24 knginx-mod-http-image-filterx86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  35 knginx-mod-http-perl      x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  45 knginx-mod-http-xslt-filterx86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  33 knginx-mod-mail           x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  64 knginx-mod-stream         x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  85 k
启用模块流:nginx                           1.14                                                  事务概要
========================================================================================
安装  8 软件包总计:881 k
安装大小:2.0 M
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务准备中  :                                                                                                                           1/1 运行脚本: nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                            1/8 安装    : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                            1/8 安装    : nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                 2/8 运行脚本: nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                 2/8 安装    : nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                         3/8 运行脚本: nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                         3/8 安装    : nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                  4/8 运行脚本: nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                  4/8 安装    : nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                              5/8 运行脚本: nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                              5/8 安装    : nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                           6/8 安装    : nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                       7/8 运行脚本: nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                       7/8 安装    : nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                            8/8 运行脚本: nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                            8/8 验证    : nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                       1/8 验证    : nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                           2/8 验证    : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                            3/8 验证    : nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                 4/8 验证    : nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                         5/8 验证    : nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                  6/8 验证    : nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                              7/8 验证    : nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                            8/8 已安装:nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                     nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                                         nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                                          nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                               nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                       nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                            nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                          完毕!
[root@localhost yum.repos.d]# 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com