封装虚拟机:将一个虚拟机设置成类似于一个安装包的东西,可以快速复制出多个虚拟机,reset的原理
创建虚拟机
选择本地镜像
![]()
![]()
选择内存为512m,不是使用图形界面就足够了
![]()
![]()
![]()
![]()
![]()
![]()
![]()
g
![]()
Partion Type(分区类型)有三种: Use entire drive 使用全部的磁盘; Replace existing linux system 替换现有的linux系统 Use free space 使用剩余空间 由于是全新安装,三种任意 都可以
![]()
![]()
![]()
![]()
配置源虚拟机
在虚拟机中删除 /etc/udev/reles.d 目录中 70开头的文件,rm -fr * 如果不删除,当网卡启动的时候这个udev规则文件会分配一个网卡名称给你的网卡

关闭防火墙设置开机不启动防火墙


设置selinux为disabled模式

配置网络

配置yum仓库


配置yum仓库时,桥接出现的问题,
配置虚拟机网卡,桥接到br0,就好了!

安装常用软件
yum install vim openssh-clients lftp
更改主机名

配置本地解析

关闭虚拟机
清除虚拟机缓存

处理这个问题时遇到了一个问题,真机并没有这个命令。
which virt-sysprep 查看该命令的位置
yum provides */virt-sysprep 查看包含/virt-sysprep命令的安装包

du -h base.qcow2 查看大小
virt-sparsify --compress base.qcow2 new.qcow2 压缩base.qcow2为new.qcow2
创建子虚拟机
qemu-img create -f qcow2 -b base.qcow2 vm1




依次创建虚拟机
对创建好的虚拟机更改主机名,并且配置好ip。
就这样成功了!
网友评论