码迷,mamicode.com
首页 > 其他好文 > 详细

kvm 克隆虚拟机

时间:2016-07-04 23:41:19      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:

两步:
第一步导出XML:
[root@ok ~]# virsh dumpxml centos02 >12c.xml

第二步磁盘文件
[root@ok virhost]# cp centos02.img 12c.img
看看两个文件的不同:
[root@ok ~]# diff /etc/libvirt/qemu/centos02.xml ~/12c.xml 
1,10c1,3
< <!--
< 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 centos02
< or other application using the libvirt API.
< -->
< 
< <domain type=‘kvm‘>
<   <name>centos02</name>
<   <uuid>e6852c4a-c0a8-cbcc-d556-768e93d4167c</uuid>
---
> <domain type=‘kvm‘ id=‘2‘>
>   <name>12c</name>
>   <uuid>e6852c4a-c0a8-cbcc-d556-768e93d4168c</uuid>
31c24
<       <source file=‘/home/virhost/centos02.img‘/>
---
>       <source file=‘/home/virhost/12c.img‘/>
32a26
>       <alias name=‘virtio-disk0‘/>
38a33
>       <alias name=‘ide0-1-0‘/>
41a37
>       <alias name=‘usb0‘/>
44a41
>       <alias name=‘usb0‘/>
48a46
>       <alias name=‘usb0‘/>
52a51
>       <alias name=‘usb0‘/>
56a56
>       <alias name=‘ide0‘/>
60c60
<       <mac address=‘52:54:00:19:77:7c‘/>
---
>       <mac address=‘52:54:00:19:77:8c‘/>
61a62,63
>       <target dev=‘vnet1‘/>
>       <alias name=‘net0‘/>
64a67
>       <source path=‘/dev/pts/2‘/>
65a69
>       <alias name=‘serial0‘/>
67c71,72
<     <console type=‘pty‘>
---
>     <console type=‘pty‘ tty=‘/dev/pts/2‘>
>       <source path=‘/dev/pts/2‘/>
68a74
>       <alias name=‘serial0‘/>
71c77
<     <graphics type=‘vnc‘ port=‘6002‘ autoport=‘no‘ listen=‘0.0.0.0‘>
---
>     <graphics type=‘vnc‘ port=‘6012‘ autoport=‘no‘ listen=‘0.0.0.0‘>
75a82
>       <alias name=‘video0‘/>
78a86
>       <alias name=‘balloon0‘/>
81a90,93
>   <seclabel type=‘dynamic‘ model=‘selinux‘ relabel=‘yes‘>
>     <label>system_u:system_r:svirt_t:s0:c355,c689</label>
>     <imagelabel>system_u:object_r:svirt_image_t:s0:c355,c689</imagelabel>
>   </seclabel>
82a95
> 

 

[root@ok ~]# virsh define 12c.xml 
Domain 12c defined from 12c.xml
root@ok ~]# virsh start 12c
Domain 12c started

[root@ok ~]# virsh list
 Id    Name                           State
----------------------------------------------------
 1     win7                           running
 2     centos02                       running
 3     12c                            running

 可以把/etc/sysconfig/network-script/ifcfg-eth0里面的MAC UUID都可以删除了

#pwd
#/etc/udev/rules.d
#rm  -f 70-persistent-net.rules
然后重启
[root@ok virhost]# virsh list
 Id    Name                           State
----------------------------------------------------
 1     win7                           running
 2     centos02                       running
 3     12c                            running

 

kvm 克隆虚拟机

标签:

原文地址:http://www.cnblogs.com/bass6/p/5641990.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!