光盘搭载yum源教程

光盘搭载yum源

TIPS
这里建议断网试验光盘yum源,因为光盘yum源主要针对无网络的情况下

1、首先要挂载你的光盘

光盘搭载yum源教程_第1张图片
光盘搭载yum源教程_第2张图片
这时候先看下有没有挂载

[root@localhost yum.repos.d]# ls -l /mnt/cdrom
总用量 664
-rw-rw-r--. 3 root root     14 9月   5 2017 CentOS_BuildTag
drwxr-xr-x. 3 root root   2048 9月   5 2017 EFI
-rw-rw-r--. 3 root root    227 8月  30 2017 EULA
-rw-rw-r--. 3 root root  18009 12月 10 2015 GPL
drwxr-xr-x. 3 root root   2048 9月   5 2017 images
drwxr-xr-x. 2 root root   2048 9月   5 2017 isolinux
drwxr-xr-x. 2 root root   2048 9月   5 2017 LiveOS
drwxrwxr-x. 2 root root 641024 9月   5 2017 Packages
drwxr-xr-x. 2 root root   4096 9月   5 2017 repodata
-rw-rw-r--. 3 root root   1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 3 root root   1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root   2883 9月   6 2017 TRANS.TBL

上面显示已经挂载了,若没有挂载
自行手动挂载如下:

[root@localhost yum.repos.d]# mount /dev/sr0 /mnt/cdrom
mount: /dev/sr0 写保护,将以只读方式挂载
mount: /dev/sr0 已经挂载或 /mnt/cdrom 忙
       /dev/sr0 已经挂载到 /mnt/cdrom 上
[root@localhost yum.repos.d]# ls -l /mnt/cdrom
总用量 664
-rw-rw-r--. 3 root root     14 9月   5 2017 CentOS_BuildTag
drwxr-xr-x. 3 root root   2048 9月   5 2017 EFI
-rw-rw-r--. 3 root root    227 8月  30 2017 EULA
-rw-rw-r--. 3 root root  18009 12月 10 2015 GPL
drwxr-xr-x. 3 root root   2048 9月   5 2017 images
drwxr-xr-x. 2 root root   2048 9月   5 2017 isolinux
drwxr-xr-x. 2 root root   2048 9月   5 2017 LiveOS
drwxrwxr-x. 2 root root 641024 9月   5 2017 Packages
drwxr-xr-x. 2 root root   4096 9月   5 2017 repodata
-rw-rw-r--. 3 root root   1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 3 root root   1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root   2883 9月   6 2017 TRANS.TBL

二、改名yum源名字,只保留光盘yum源

tips:
yum源在: /etc/yum.repos.d
文件夹下

网络yum源 :CentOS-Base.repo
光盘yum源:CentOS-Media.repo

[root@localhost yum.repos.d]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ls -l
总用量 32
-rw-r--r--. 1 root root 1664 8月  30 2017 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 8月  30 2017 CentOS-CR.repo
-rw-r--r--. 1 root root  649 8月  30 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 8月  30 2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  659 12月 15 09:40 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 8月  30 2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 8月  30 2017 CentOS-Vault.repo
-rw-r--r--. 1 root root  664 5月  11 2018 epel-7.repo

这里除了光盘yum源外其他yum源都添加后缀 .bak

改名 用 mv
举例: mv CentOS-Base.repo CentOS-Base.repo.bak

-rw-r--r--. 1 root root 1664 8月  30 2017 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 8月  30 2017 CentOS-CR.repo.bak
-rw-r--r--. 1 root root  649 8月  30 2017 CentOS-Debuginfo.repo.bak
-rw-r--r--. 1 root root  314 8月  30 2017 CentOS-fasttrack.repo.bak
-rw-r--r--. 1 root root  659 12月 15 09:40 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 8月  30 2017 CentOS-Sources.repo.bak
-rw-r--r--. 1 root root 3830 8月  30 2017 CentOS-Vault.repo.bak
-rw-r--r--. 1 root root  664 5月  11 2018 epel-7.repo.bak

三、修改配置文件 vim CentOS-Media.repo

[root@localhost yum.repos.d]# vim CentOS-Media.repo 

光盘搭载yum源教程_第3张图片
记得保存退出!!

四、安装你的rpm包

可以输入:
yum list
看哪些包可以下载,挑一个试一试
这里可以看到每一行最后显示你的光盘yum源(我的是 CentOS7-Media)
然后 yum -y install 包全名 下载包

五、查询是否下载

rpm -qa | grep 包名
注意:这里是包名!!!(如果不清楚包名和包全名自行百度)

你可能感兴趣的:(Linux,linux,yum)