CentOS 8挂载本地源

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 k
 nginx-filesystem         noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  24 k
 nginx-mod-http-image-filter
                          x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  35 k
 nginx-mod-http-perl      x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  45 k
 nginx-mod-http-xslt-filter
                          x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  33 k
 nginx-mod-mail           x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream  64 k
 nginx-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]# 

  • 7
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黑蛋同志

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值