KVM Snapshot Management
1. Create a Snapshot
Virsh snapshot-create Daixuan1
[Email protected] ~]# Virsh snapshot-create daixuan1
Domain Snapshot 1455801179 created
View Snapshots
[Email protected] ~]# qemu-img info/data/daixuan1. Qcow2
Image:/data/daixuan1.qcow2
File Format:qcow2
Virtual size:10g (10737418240 bytes)
Disk size:10g
cluster_size:65536
Snapshot list:
ID TAG vm SIZE DATE VM CLOCK
1 1455801179 0 2016-02-18 21:12:59 00:00:00.000
Note: Disk mirroring conversion format, creating snapshots
Create Snapshot if error:
Unsupported configuration:internal snapshot for disk Vdas unsupported for storage type raw
This is because the daixuan1.img file is not a snapshot of the image in raw format, so you need to convert the format first to see the current sub-machine disk image format
Qemu-img info/data/centos6.6_1.img
The result is:
Image:/data/centos6.6_1.img
File format:Raw (the format must be qcow2 before you can take a snapshot)
Virtual size:30g (32212254720 bytes)
Disk size:1.6g
Convert RAW format to Qcow format (in fact, copy one):
qemu-img convert-f raw-o qcow2/data/centos6.6_1.img/data/centos6.6_1.qcow2
-F Raw Original format
-O qcow2 Conversion format
Qemu-img Info/data/centos6.6_1.qcow2//View the format again, the results are as follows
Image:/data/centos6.6_1.qcow2
File format:Qcow2
Virtual size:30g (32212254720 bytes)
Disk size:1.1g
cluster_size:65536
Now we also need to edit the sub-machine configuration file so that it uses the new format of the vdisk image file
Virsh Edit Centos6.6_1//This will enter the sub-machine configuration file, equivalent to use the following VI
Vi/etc/libvirt/qemu/centos6.6_1
(/etc/libvirt/qemu/centos6.6_1.xml), with the same use of vim editing this file
The places to be modified are:
<drivername= ' qemu ' type= ' raw 'Cache= ' None '/>
<sourcefile= '/data/centos6.6_1.img '/>
Switch
<drivername= ' qemu ' type= ' Qcow2 'Cache= ' None '/>
<sourcefile= '/data/centos6.6_1.qcow2 '/>
Continue creating snapshots
Virsh snapshot-create Centos6.6_1//This time the success, prompted the following
Domain Snapshot 1437248443 created
2. List snapshots:
[Email protected] ~]# Virsh snapshot-list daixuan1
Name Creation time Status
------------------------------------------------------------
1455801179 2016-02-18 21:12:59 +0800 shutoff
3. Recovering snapshots
You need to shut down the sub-machine first
Virsh Destroy Daixuan1
Confirm that the sub-machine is off
Virsh domstate Daixuan1
Shut down
[Email protected] ~]# Virsh snapshot-revert daixuan1 1455801179
[Email protected] ~]# Virsh snapshot-list daixuan1//Result Yes
Name Creation time Status
------------------------------------------------------------
1455801179 2016-02-18 21:12:59 +0800 shutoff
4. View the snapshot version of the current sub-machine:
[Email protected] ~]# Virsh snapshot-current daixuan1
<domainsnapshot>
<name>1455801179</name>
5. Deleting snapshots
[Email protected] ~]# Virsh snapshot-delete daixuan1 1455801179
Domain Snapshot 1455801179 deleted
[Email protected] ~]# Virsh snapshot-list daixuan1
Name Creation time Status
Snapshot files for Daixuan1 sub-machine in/var/lib/libvirt/qemu/snapshot/daixuan1/directory
[[email protected] ~]# ls/var/lib/libvirt/qemu/snapshot/daixuan1///No snapshots already
This article is from the "Daixuan" blog, make sure to keep this source http://daixuan.blog.51cto.com/5426657/1743044
KVM Snapshot Management