libvirt-使用iso镜像创建主机&修改启动盘&启动

非专业人士,有错请指出
首先创建一个空的镜像:
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
成功~!

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值