006. kvm vm clone

Source: Internet
Author: User
Clone a KVM Host Machine 1.1 to view VM configurations
1 [[email protected] ~] # Cat/etc/libvirt/qemu/vm01-centos6.8.xml 2 ............ 3 [[email protected] ~] # Ll/data/images/# VM disk file 4 total 1.3G 5-RW -------. 1 qemu 21G May 27 vm01-centos6.8.img 6 7 [[email protected] ~] # Virsh list -- all # Virtual Machine name 8 id name state 9 -------------------------------------------------- 10-vm01-centos6.8 shut off
1.2 clone operation
  1 [[email protected] ~]# virt-clone -o vm01-centos6.8 -n vm02-centos6.8 -f /data/images/vm02-centos6.8.img

Note: You can also use the following syntax --

  1 virt-clone --connect qemu:///system --original vm01-centos6.8 --name vm02-centos6.8 --file /data/images/vm02-centos6.8.img 
  1 [[email protected] ~]# virsh list --all  2  Id    Name                           State  3 ----------------------------------------------------  4  -     vm01-centos6.8                 shut off  5  -     vm02-centos6.8                 shut off

Suggestion: We recommend that you shut down or suspend the clone operation.

1.3 start and configure a new VM
1 [[email protected] ~] # Virsh start vm02-centos6.8 2 [[email protected] ~] # Virsh Console 3 # Enter VM 3 [[email protected] ~] # Vi/etc/hosts # modify as needed 4 [[email protected] ~] # Vi/etc/sysconfig/Network # modify 5 as needed [[email protected] ~] # Vi/etc/sysconfig/net-scripts/ifcfg-eth0 6 device = eth0 7 hwaddr = 52: 54: 00: B0: 6B: DC 8 onboot = yes # Start 9 nm_controlled = yes 10 bootproto = static 11 ipaddr = 172.24.8.41 12 netmask = 255.255.255.0 13 gateway = 172.24.8.2 14 [[email protected] ~] # Vi/etc/udev/rules. d/70-persistent-net.rules 15 # PCI device 0x1af4: 0x1000 (virtio-PCI) 16 subsystem = "Net", Action = "add", drivers = "? * ", ATTR {address} =" 52: 54: 00: B0: 6B: DC ", ATTR {type} =" 1 ", kernel = "ETH *", name = "eth0" 17 [[email protected] ~] # Shutdown-R now # restart takes effect

Tip:

1: If DHCP exists in the LAN, you can enable it. If it does not exist, you can configure a static IP address in the same network segment as the host.

# Ifconfig eth0 up

# Dhclient eth0

2: the MAC address must be consistent with the KVM xml configuration file and globally unique. Check that the address is <MAC address = '52: 54: 00: B0: 6B: dc'/>.

3: We recommend that you modify IP, Mac, UUID, and other information to prevent conflicts with the source host.

Clone 2.1 Between Two machines to view Virtual Machine configurations
  • Source Host Name: vm01-centos6.8
  • Source host configuration file:/etc/libvirt/qemu/vm01-centos6.8.xml
  • Source host Disk Files:/data/images/vm01-centos6.8.img
  • Clone Host Name: vm03-centos6.8
  • Clone host profile:/etc/libvirt/qemu/vm03-centos6.8.xml
  • Clone host Disk File:/data/images/vm03-centos6.8.img

Suggestion: We recommend that you shut down or suspend the clone operation.

2.1 copy the configuration file
  1 [[email protected] ~]# virsh dumpxml vm01-centos6.8 > /etc/libvirt/qemu/vm03-centos6.8.xml
2.2 copy Disk Files
  1 [[email protected] ~]# cp /data/images/vm01-centos6.8.img /data/images/vm03-centos6.8.img
2.3 modify configuration information
  1 [[email protected] ~]# vi /etc/libvirt/qemu/vm03-centos6.8.xml  2 ……  3 <name>vm03-centos6.8</name>  4 <uuid>1a35bbaf-988f-4467-abe4-5e43a97094cd</uuid>  5 ……  6 <source file=‘/data/images/vm03-centos6.8.img‘/>  7 ……  8 <graphics type=‘vnc‘ port=‘5903‘ autoport=‘no‘ listen=‘0.0.0.0‘>  9 …… 10 <mac address=‘52:54:00:7d:99:10‘/> 11 ……

Note: You must modify the preceding parameters to be inconsistent with those of the source VM.

2.4 redefinition of New VM configurations
  1 [[email protected] ~]# virsh define /etc/libvirt/qemu/vm03-centos6.8.xml
2.5 start a new VM
  1 [[email protected] ~]# virsh start vm03-centos6.8
2.6 enter new Vm and configure
  1 [[email protected] ~]# virsh console vm03-centos6.8

For more information, see section 1.3.

006. kvm vm clone

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.