CentOS7.1 KVM虚拟化之虚拟机快照(5)

这里用之前克隆的虚拟机vm1-clone进行快照操作

注:

1.快照实际上做的是虚拟机的XML配置文件,默认快照XML文件在/var/lib/libvirt/qemu/snapshot/虚拟机名/下

2.快照仅仅支持qcow2磁盘格式的系统

一、虚拟机创建快照

[root@kvm01 ~]# virsh snapshot-create vm1-clone
Domain snapshot 1457941090 created

或创建快照的同一时候,再创建一个快照别名

[root@kvm01 ~]# virsh snapshot-create-as vm1-clone first_snap

二、查看虚拟机历史快照信息

[root@kvm01 ~]# virsh snapshot-list vm1-clone
 Name                 Creation Time             State
------------------------------------------------------------
 1457941090           2016-03-14 15:38:10 +0800 running
 ylhb                 2016-03-14 16:23:04 +0800 running

三、查看虚拟机磁盘信息

[root@kvm01 ~]# qemu-img info /vm-images/vm1-clone.img
image: /vm-images/vm1-clone.img
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 3.7G
cluster_size: 65536
Snapshot list:
ID        TAG                 VM SIZE                DATE       VM CLOCK
1         1457941090             212M 2016-03-14 15:38:10   00:50:13.868
2         ylhb                   206M 2016-03-14 16:23:05   00:07:25.882
Format specific information:
    compat: 1.1
    lazy refcounts: true

能够看到里面已经含有虚拟机快照信息

四、查看当前快照信息

[root@kvm01 ~]# virsh snapshot-current vm1-clone
<domainsnapshot>
<name>ylhb</name>
<state>running</state>
<parent>
<name>1457941090</name>
</parent>
<creationTime>1457943784</creationTime>
<memory snapshot='internal'/>

五、恢复到之前快照

[root@kvm01 ~]# virsh snapshot-revert vm1-clone 1457941090

查看当前快照信息验证是否恢复成功:

[root@kvm01 ~]# virsh snapshot-current vm1-clone
<domainsnapshot>
<name>1457941090</name>
<state>running</state>
<creationTime>1457941090</creationTime>
<memory snapshot='internal'/>
<disks>

六、删除指定快照

[root@kvm01 ~]# virsh snapshot-delete vm1-clone 1457941090
Domain snapshot 1457941090 deleted
上一篇:在CentOS下源码安装 Xen并搭建Windows虚拟机


下一篇:KVM安装启动虚拟机