一、制作后端模板系统(CentOS7)
先创建后端盘:
qemu-img create -f qcow2 CentOS7.img 2G
用virt-manager使用这个后端盘,完成后进入系统调试为模板系统
注意:
制作模板系统时可提前配置virsh console可连接:
1.进入虚机中,编辑 /etc/default/grub 文件,找到下面行:
GRUB_CMDLINE_LINUX="rhgb quiet"
改为:(尾部增加 console=ttyS0,115200)
GRUB_CMDLINE_LINUX="rhgb quiet console=ttyS0,115200”
2.使用以下命令激活服务(这个是centos7才有的服务,但默认没有启动)
systemctl start serial-getty@ttyS0.service
systemctl enable serial-getty@ttyS0.service
3.重启系统验证后关机
virsh console centos7
poweroff
二、创建前端盘和xml文件
1.基于后端盘创建前端盘:
cd /var/lib/libvirt/images/
qemu-img create -f qcow2 -b CentOS7.img centos7-1.img 20G
2.创建xml配置文件(默认路径:/etc/libvirt/qemu/):
virsh dumpxml CentOS7 >centos7-1.xml
vim centos7-1.xml
<domain type='kvm'> #删除id=''
<name>myrh7_2</name> #修改虚拟机名
#删除UUID整行(会自动生成)
<source file='/var/lib/libvirt/images/centos7-1.img'/> #修改所用磁盘
#删除网卡mac地址行
#删除<channel type='unix' >闭合块
附上xml文件供直接拷贝:
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit centos7-1
or other application using the libvirt API.
-->
<domain type='kvm'>
<name>centos7-1</name> #虚拟机名
<memory unit='KiB'>1048576</memory> #内存大小
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
<bootmenu enable='yes'/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>Broadwell-noTSX-IBRS</model>
<feature policy='require' name='md-clear'/>
<feature policy='require' name=