当前位置: 移动技术网 > 网络运营>服务器>Linux > linux通过挂载系统光盘搭建本地yum仓库的方法

linux通过挂载系统光盘搭建本地yum仓库的方法

2019年04月28日  | 移动技术网网络运营  | 我要评论
1.挂载光盘 [root@localhost ~]# mount /dev/cdrom /media/cdrom/ mount: /dev/sr0 写保护,将以

1.挂载光盘

[root@localhost ~]# mount /dev/cdrom /media/cdrom/
mount: /dev/sr0 写保护,将以只读方式挂载

  /dev下的cdrom目录是事先创建好的

2.修改yum配置文件(文件位置:/etc/yum.repos.d)

[root@localhost /]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir bak    #创建一个文件夹来存放多余的配置文件
[root@localhost yum.repos.d]# mv *.* bak/      
[root@localhost yum.repos.d]# cd bak/
[root@localhost bak]# ls
centos-base.repo centos-debuginfo.repo centos-media.repo centos-vault.repo
centos-cr.repo centos-fasttrack.repo centos-sources.repo
[root@localhost bak]# mv centos-media.repo ../
[root@localhost bak]# cd ../
[root@localhost yum.repos.d]# vi centos-media.repo 
# centos-media.repo
#
# this repo can be used with mounted dvd media, verify the mount point for
# centos-7. 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=c7-media [command]
#
# or for only the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command]
[c7-media]
name=centos-$releasever - media
baseurl=file:///media/centos/
file:///media/cdrom/  #本地yum源所在路径
file:///media/cdrecorder/
gpgcheck=0 #这里为0不进行检查
enabled=1   #这里为1  启动
gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7
~ 

保存退出

3.验证

我们使用 yum 命令加上 list 参数就可以查看仓库

[root@localhost /]# yum list   #后面东西太多了。。。

以上所述是小编给大家介绍的linux通过挂载系统光盘搭建本地yum仓库的方法,希望对大家有所帮助

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网