-
创建想要挂载的路径
-
mkdir /mnt/cdrom
-
-
挂载本地镜像到创建的目录
-
mount -t iso9660 /dev/cdrom /mnt/cdrom/
-
mount: /dev/sr0 is write-protected, mounting read-only -->mount:/dev/sr0写保护,将以只读方式挂载
-
-
验证挂载是否成功
-
df
Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/centos_nginx--rtmp--model-root 17811456 1386444 16425012 8% / devtmpfs 1919520 0 1919520 0% /dev tmpfs 1931784 0 1931784 0% /dev/shm tmpfs 1931784 11824 1919960 1% /run tmpfs 1931784 0 1931784 0% /sys/fs/cgroup /dev/sda1 1038336 145244 893092 14% /boot tmpfs 386360 0 386360 0% /run/user/0 /dev/sr0 4364408 4364408 0 100% /mnt/cdrom
-
-
修改文件名
-
进入/etc/yum.repos.d/路径下,把除CentOS-Media.repo文件外,都改成其他名称(相当于逻辑删除):
-
cd /etc/yum.repos.d/
-
mv CentOS-Base.repo CentOS-Base.repo.old
-
mv CentOS-CR.repo CentOS-CR.repo.old
-
mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.old
-
mv CentOS-fasttrack.repo CentOS-fasttrack.repo.old
-
mv CentOS-Sources.repo CentOS-Sources.repo.old
-
mv CentOS-Vault.repo CentOS-Vault.repo.old
-
-
-
编辑文件
-
vim /etc/yum.repos.d/CentOS-Media.repo
把baseurl的位置指向挂载的文件路径 把enable改成1 [c7-media] name=CentOS-$releasever - Media baseurl=file:///mnt/cdrom/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
-
-
验证
-
使用yum安装yum install -y vim,命令正常执行,证明配置成功
-