如何让新创建的虚拟机可以安装官方软件 ?
虽然虚拟机也是用镜像封装的,但是安装虚拟机时只下载了镜像里的部分安装包 还有好多安装包并没有下载
我们可以把镜像光盘导入虚拟机,以通过搭建yum仓库,来下载镜像里没有下载的其他安装包
@1导入光盘
注意:导入之前,必须先关机(force off),这样才能生效
@2挂载
[[email protected] ~]# df
[[email protected] ~]# mkdir /rhel7.2
[[email protected] ~]# mount /dev/sr1 /rhel7.2
[[email protected] ~]# df
@3编写文件
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# ls
redhat.repo
##以.repo结尾的文件名均可
[[email protected] yum.repos.d]# vim rhel.repo
##################
[rhel7.2] #名字
name=rhel7.2 #说明
baseurl=file:///rhel7.2 #file:// 表示本地文件
gpgcheck=0 #0表示安装软件时无需检测(1代表需要检测)
[[email protected] yum.repos.d]# cd
##清空缓存
[[email protected] ~]# yum clean all
##列出yum源的详细信息
[[email protected] ~]# yum repolist
测试:
##安装hdcp服务
[[email protected] ~]# yum install -y dhcp
@@也可以导入光盘后无需挂载,直接编写文件
##重启后之前的挂载便会失效,因为是临时挂载
[[email protected] ~]# reboot
[[email protected] ~]# df
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# ls
redhat.repo rhel.repo
[[email protected] yum.repos.d]# vim rhel.repo
#############################
[rhel7.2] #仓库名称
name=hello word! #说明
baseurl=file:///run/media/root/RHEL-7.2\ Server.x86_64 #file://表示本地文件; /run/media/root/RHEL-7.2\ Server.x86_64 为镜像文件的挂载点
gpgcheck=0 #安装软件时不检测
##清空缓存
[[email protected] yum.repos.d]# yum clean all
##列出yum源的详细信息
[[email protected] yum.repos.d]# yum repolist