Quick understanding of Snapshots Please refer to virtual machine snapshot analysis
Objective:
Through a basic image (backing files, the basic image), inside the various virtual machines need to set up the environment, and then based on this image to establish an incremental image, each incremental image corresponding to a virtual machine, the virtual machine on the mirror all the changes are recorded in the incremental image inside, The underlying image is always intact.
Features: Save disk space and quickly replicate virtual machines.
Environment:
Basic image file: Vm4.qcow2 virtual machine ID:VM4
Incremental image file: Vm5.qcow2 virtual machine ID:VM5
Requirements: Create a virtual machine VM5 by creating a mirrored file Vm5.qcow2 based on the basic image file Vm4.qcow2, and the changes to the virtual machine node4 will be stored in vm5.qcow2.
1. View backing files Information
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/C3/wKiom1WnbXDxthLcAAGPZ-jdMAM473.jpg "title=" 1.jpg " alt= "Wkiom1wnbxdxthlcaagpz-jdmam473.jpg"/>
2. Create a snapshot Delta file
[Email protected] kvm]# qemu-img create-b vm4.qcow2-f qcow2 vm5.qcow2
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/C3/wKiom1WnbfjBJhrfAAFGwBNpUH8725.jpg "title=" 1.jpg " alt= "Wkiom1wnbfjbjhrfaafgwbnpuh8725.jpg"/>
3. Create VM5 configuration file and modify
[[email protected] kvm]# cp /etc/libvirt/qemu/vm4.xml /etc/libvirt/qemu/vm5.xml[[ email protected] kvm]# vim /etc/libvirt/qemu/vm5.xml###### #对比和源vm4的配置文件 ###########[[email protected] kvm]# diff /etc/libvirt/qemu/vm4.xml /etc/libvirt/qemu/vm5.xml 9,10c9,10< <name>vm4</name>< <uuid> 4e7de5d2-fab4-958f-1aba-2da41690fd07</uuid>---> <name>vm5</name>> <uuid>4e7de5d2-fab4-958f-1aba-2da41690fd08</uuid>31c31< <source file= '/kvm/vm4.qcow2 '/>---> <source file= '/kvm/vm5.qcow2 '/>48c48< <mac address= ' 52:54:00:41:d6:44 '/>---> <mac address= ' 52:54:00:41:d6:45 '/>60c60< &Nbsp; <graphics type= ' vnc ' port= ' 5913 ' autoport= ' no ' listen= ' 0.0.0.0 ' >---> <graphics type= ' vnc ' port= ' 5915 ' autoport= ' no ' listen= ' 0.0.0.0 ' >
4, according to the configuration file definition VM5 virtual machine
[Email protected] kvm]# Virsh define/etc/libvirt/qemu/vm5.xml [[email protected] kvm]# Virsh start VM5
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/C4/wKiom1WncM3hek_FAATXgcIyTg0651.jpg "title=" 1.jpg " alt= "Wkiom1wncm3hek_faatxgciytg0651.jpg"/>
Enter the system to modify the necessary configuration; hostname, network card, more than 6.0 system Delete file/etc/udev/rules.d/70-persistent-net.rules
5. Automatic expansion of virtual machine capacity
[[email protected] kvm]# cd/kvm/[[email protected] kvm]# du-sh vm4.qcow2 vm5.qcow2 1.6G vm4.qcow26.9m vm5.qcow2[[e Mail protected] kvm]#
In the VM5 host simulation
[[email protected] ~]# dd If=/dev/zero of=testfile bs=1m count=500 recorded 500+0 read write 524288000 bytes (500+0 MB) copied, 16.662 seconds , 31.5 mb/s [[email protected] ~]#
can see the change
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/C1/wKioL1WndO_i3NS4AADE_Q3fRLY004.jpg "title=" 1.jpg " alt= "Wkiol1wndo_i3ns4aade_q3frly004.jpg"/>
The underlying file does not change, incremental file changes
This article is from the "Big Wind" blog, please be sure to keep this source http://lansgg.blog.51cto.com/5675165/1675362
Incremental host snapshot for KVM (v) client VMS