1. 加载 CentOS的ISO镜像并挂载:
[[email protected] files]# mount /media/files/CentOS-7-x86_64-DVD-1611.iso /mnt/cdrom/
mount: /dev/loop0 写保护,将以只读方式挂载
2. 新建CentOS目录并把光盘上的文件复制到该目录下:
[[email protected] files]# mkdir /media/CentOS/
[[email protected] files]# cp -fr /mnt/cdrom/* /media/CentOS/
3. 修改yum配置文件:
[[email protected] /]# vi /etc/yum.repos.d/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/ -->这一行改成前边我们新建的CentOS目录
# file:///media/cdrom/ -->这一行加#号注释掉
# file:///media/cdrecorder/ -->这一行加#号注释掉
gpgcheck=1
enabled=1 -->这一行把0改成1来启用源
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
按 “i” 键 修改红色标记的地方,然后输入 :wq 保存退出。
4. 卸载镜像:
[[email protected] /]# umount /mnt/cdrom/
2017-08-17 18:21:46 @sh hp