CentOS6 搭建本地光盘yum源

前言:

        本次配置本地光盘yum源的目的就是为安装gcc编译器做准备,由于编译 ntfs-3g_ntfsprogs-2021.8.22 时,提示缺少编译器,要安装编译器,就需要配置yum源,所以这里记录下如何配置本地光盘yum源的过程

配置步骤:

第一步、进入yum源配置文件/etc/yum.repos.d/

[root@localhost ntfs-3g_ntfsprogs-2021.8.22]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Vault.repo

        说明:默认网络yum源生效,即CentOS-Base.repo生效,要配置光盘yum源需要使其失效,方法有很多,这里采取修改文件名实现。

第二步,修改网络yum源名字,使网络yum源失效

[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost yum.repos.d]# ls
CentOS-Base.repo.bak  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Vault.repo

第三步、挂载本地光盘

       1、 挂载前准备,选定光盘镜像文件。

CentOS6 搭建本地光盘yum源_第1张图片

         2、挂载前补充

光盘设备文件名

        CentOS 5.x 设备文件名是/dev/hdc

        CentOS 6.x 设备文件名是/dev/sr0

光盘挂载位置

        /mnt/cdrom

        3、挂载光盘

[root@localhost ~]# mount -t iso9660 /dev/sr0 /mnt/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only

        说明:挂载之后提示为read-only表示挂载成功。

第四步、修改yum源配置文件,让光盘yum源生效

 [root@localhost yum.repos.d]# vi CentOS-Media.repo
 ...
 14 [c6-media]
 15 name=CentOS-$releasever - Media
 16 baseurl=file:///mnt/cdrom/
 17 #        file:///media/cdrom/
 18 #        file:///media/cdrecorder/
 19 gpgcheck=1
 20 enabled=1
 21 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 ...

第五步、验证光盘yum源

[root@localhost yum.repos.d]# yum list | more
已加载插件:fastestmirror, security
Loading mirror speeds from cached hostfile
已安装的软件包
ConsoleKit.x86_64                           0.4.1-6.el6                 @anaconda-CentOS-201605220104.x86_64/6.8
ConsoleKit-libs.x86_64                      0.4.1-6.el6                 @anaconda-CentOS-201605220104.x86_64/6.8
ConsoleKit-x11.x86_64                       0.4.1-6.el6                 @anaconda-CentOS-201605220104.x86_64/6.8
GConf2.x86_64                               2.28.0-6.el6                @anaconda-CentOS-201605220104.x86_64/6.8
MAKEDEV.x86_64                              3.24-6.el6                  @anaconda-CentOS-201605220104.x86_64/6.8
ORBit2.x86_64                               2.14.17-5.el6               @anaconda-CentOS-201605220104.x86_64/6.8
SDL.x86_64                                  1.2.14-7.el6_7.1            @anaconda-CentOS-201605220104.x86_64/6.8
abrt.x86_64                                 2.0.8-40.el6.centos         @anaconda-CentOS-201605220104.x86_64/6.8
abrt-addon-ccpp.x86_64                      2.0.8-40.el6.centos         @anaconda-CentOS-201605220104.x86_64/6.8
abrt-addon-kerneloops.x86_64                2.0.8-40.el6.centos         @anaconda-CentOS-201605220104.x86_64/6.8
abrt-addon-python.x86_64                    2.0.8-40.el6.centos         @anaconda-CentOS-201605220104.x86_64/6.8
abrt-cli.x86_64                             2.0.8-40.el6.centos         @anaconda-CentOS-201605220104.x86_64/6.8
abrt-libs.x86_64                            2.0.8-40.el6.centos         @anaconda-CentOS-201605220104.x86_64/6.8
...

        验证成功!

小结:

        挂载过程总体顺利,有点小波折,实属正常,不必在意!

你可能感兴趣的:(CentOS6,linux,centos,运维)