非专业人士,有错请指出
首先创建一个空的镜像:
sudo qemu-img create -f qcow2 centos_xxx_0601.qcow2 100G
接下来修改libvert_xxx.xml文件,启动盘为cdrom,从iso安装系统
<domain type="kvm">
<name>instance-new</name> <!-- 虚拟机名称 -->
<memory>16777216</memory> <!-- 内存-->
<vcpu>4</vcpu> <!-- cpu -->
<os>
<type>hvm</type>
<boot dev="cdrom"/> <!-- 虚拟机开机引导项设置为光盘-->
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset="utc">
<timer name="pit" tickpolicy="delay"/>
<timer name="rtc" tickpolicy="catchup"/>
<timer name="hpet" present="no"/>
</clock>
<cpu mode="host-model" match="exact">
<topology sockets="2" cores="2" threads="1"/>
</cpu>
<devices>
<disk device="disk" type="file">
<target bus="virtio" dev="hda"/>
<source file="/var/log/cloud/new_smc/centos_smc_170601.qcow2"/>
<driver type="qcow2" name="qemu"/>
</disk>
<disk device="cdrom" type="file">
<target bus="ide" dev="hdc"/>
<source file="/var/log/cloud/new_smc/smc_v1.0.0.170524_1526.iso"/>
<driver type="raw" name="qemu"/>
</disk>
<interface type="bridge">
<source bridge="br-powervc"/>
<model type="virtio"/>
</interface>
<interface type="bridge">
<source bridge="br-powervc"/>
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="vnc" autoport="yes" keymap="en-us" listen="0.0.0.0"/>
<video>
<model type="cirrus"/>
</video>
<memballoon model="virtio">
<stats period="10"/>
</memballoon>
</devices>
</domain>
接下来是define
virsh define libvert_xxx.xml
然后开机
virsh start instance-new
使用vnc连接主机,进行系统安装
virsh vncdisplay instance-new
安装完成之后进行destroy
virsh destroy instance-new
修改xml文件,开机引导项设置为硬盘
<os>
<type>hvm</type>
<boot dev="hd"/> <!-- 虚拟机开机引导项设置为硬盘-->
</os>
为了使新的xml文件生效
一定要执行undefine instance-new
!
一定要执行undefine instance-new
!
一定要执行undefine instance-new
!
重要的事情说三遍
接下来 virsh define libvert_xxx.xml
启动虚拟机 virsh start instance-new
成功~!