CentOS搭建光盘yum源

一、挂载光盘

mount /dev/sr0 /mnt/cdrom

二、使网络yum源失效

cd /etc/yum.repos.d      #进入yum源目录
mv CentOS-Base.repo CentOS-Base.repo.bak     #修改yum源文件后缀 使其失效

不建议你删掉源文件,改个名字就可以了。防止后面要用。

三、使光盘yum源生效

vi CentOS-Media.repo 进入光盘yum源文件
修改 baseurl=file:///mnt/cdrom/ #注释其他地址
修改 enabled=1

[root@wangteng yum.repos.d]# cat CentOS-Media.repo 
# CentOS-Media.repo
#
# This repo is used to mount the default locations for a CDROM / DVD on
#  CentOS-6.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c6-media [command]
#  
# or for ONLY the media repo, do this:
#
#  yum --disablerepo=\* --enablerepo=c6-media [command]
 
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
#       file:///media/cdrom/
#       file:///media/cdrecorder/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

注意:

#       file:///media/cdrom/
#       file:///media/cdrecorder/

这两行一定要注释掉,不然每次都会出现两个报错,但是不影响使用注意在注释的时候,#号不能缩进。

四、yum list 

可以查看yum源里有哪些软件包可以安装。

发布了44 篇原创文章 · 获赞 6 · 访问量 6329

猜你喜欢

转载自blog.csdn.net/annita2019/article/details/104229860