搭建虚拟机yum仓库

虽然虚拟机也是用镜像下载的,但是只下载了镜像里的部分安装包在虚拟机里 还有好多安装包并没有下载,我们可以把镜像导入到虚拟机里,以通过搭建yum仓库,来下载镜像里没有下载的其他安装包

1.配置虚拟机网络

[root@localhost Desktop]# ifconfig   # 先查看系统有什么设备

在这里插入图片描述

[root@localhost Desktop]# vim /etc/sysconfig/network-scripts/ifcfg-eth0  # 给eth0设备设定ip  
	1 BOOTPROTO=none  
	2 NAME=eth0  
	3 DEVICE=eth0     # 上面查看到的设备是什么名称,就在此处写什么
	4 ONBOOT=yes  
	5 IPADDR=172.25.254.142  
	6 PREFIX=24
[root@localhost Desktop]# systemctl restart network

2.给虚拟机添加光盘(先要关闭虚拟机)

[root@foundation42 mnt]# virt-manager    # 在真机上执行这条命令

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

[root@localhost Desktop]# df

在这里插入图片描述

[root@localhost Desktop]# mkdir /rhel7.2/     # 自己创建挂载点

临时挂载
[root@localhost Desktop]# mount /dev/sr0 /rhel7.2/   # 把光驱挂载到自己新建的挂载点上 
mount: /dev/sr0 is write-protected, mounting read-only
永久挂载
[root@localhost Desktop]# vim /etc/rc.d/rc.local  # 里面的内容是开机的时候读取的脚本
[root@localhost Desktop]# chmod +x /etc/rc.d/rc.local
[root@localhost Desktop]# ll /etc/rc.d/rc.local
-rwxr-xr-x. 1 root root 498 Oct 27 09:53 /etc/rc.d/rc.local
[root@localhost Desktop]# reboot
[root@localhost Desktop]# df

在这里插入图片描述

[root@localhost Desktop]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim yum.repo     # 搭建仓库
	1 [rhel7.2]  
	2 name=rhel7.2  
	3 baseurl=file:///rhel7.2  
	4 gpgcheck=0

在这里插入图片描述

[root@localhost yum.repos.d]# yum clean all    # 清除缓存
[root@localhost yum.repos.d]# yum repolist     # 列出镜像里的内容

在这里插入图片描述

[root@localhost yum.repos.d]# yum list dhcp   # 列出dhcp的安装包,能列出来就说明可以下载

在这里插入图片描述

[root@localhost yum.repos.d]# yum install -y dhcp.x86_64   # 此时就可以下载了	

猜你喜欢

转载自blog.csdn.net/wzt888_/article/details/83277934