系统版本

[root@desktop2 ~]# cat /proc/version
Linux version 2.6.32-220.el6.x86_64 (mockbuild@x86-004.build.bos.redhat.com) (gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC) ) #1 SMP Wed Nov 9 08:03:13 EST 2011
[root@desktop2 ~]#

为虚拟机创建快照

[root@desktop2 ~]# lvs
  LV           VG   Attr   LSize   Origin  Snap%  Move Log Copy%  Convert
  home         vol0 -wi-ao 512.00m                                       
  root         vol0 -wi-ao   8.00g                                       
  vserver      vol0 owi-a-  10.00g                                       
  vserver-snap vol0 swi-a-   4.00g vserver   0.89                        
[root@desktop2 ~]# lvcreate -L 1G -s -n vserver2 /dev/vol0/vserver
  Logical volume "vserver2" created
[root@desktop2 ~]# lvs
  LV           VG   Attr   LSize   Origin  Snap%  Move Log Copy%  Convert
  home         vol0 -wi-ao 512.00m                                       
  root         vol0 -wi-ao   8.00g                                       
  vserver      vol0 owi-a-  10.00g                                       
  vserver-snap vol0 swi-a-   4.00g vserver   0.89                        
  vserver2     vol0 swi-a-   1.00g vserver   0.00  


生成新的uuid

[root@desktop2 ~]# uuidgen
1440f78a-3f93-4a84-be09-bef93c3188e3

导出vserver虚拟机的配置信息,并修改4处客户化信息

[root@desktop2 ~]# virsh dumpxml vserver > /tmp/vserver2.xml
[root@desktop2 ~]# vim /tmp/vserver2.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 vserver2
or other application using the libvirt API.
-->

<domain type='kvm'>
  <name>vserver2</name>
  <uuid>1440f78a-3f93-4a84-be09-bef93c3188e3</uuid>
  <memory>2097152</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>2</vcpu>
  <os>
    <type arch='x86_64' machine='rhel6.2.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/vol0/vserver2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <interface type='bridge'>
      <mac address='52:54:00:00:00:02'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
</domain>
[root@desktop2 ~]#


生成克隆虚拟机

[root@desktop2 ~]# virsh define /tmp/vserver2.xml
Domain vserver2 defined from /tmp/vserver2.xml


启动克隆虚拟机
[root@desktop2 ~]# virsh start vserver2
Domain vserver2 started

[root@desktop2 ~]# virsh list
 Id Name                 State
----------------------------------
  3 vserver2             running




Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐