KVM 快照的定义:快照就是将虚机在某一个时间点上的磁盘、内存和设备状态保存一下,以备将来之用
KVM的快照功能和VMware一样,可以实现热备和回滚的功能,在进行快照之前需要确保磁盘格式必须是QCOW2,因为RAW格式是不支持快照的
1、查看虚拟机
[root@localhost ~]# virsh list --all
Id Name State
----------------------------------------------------
1 kvm107 running
2、创建指定虚拟机快照
[root@localhost ~]# virsh snapshot-create-as kvm107 kvm107-snap
Domain snapshot kvm107-snap created
3、查看指定虚拟机快照
[root@localhost ~]# virsh snapshot-list kvm107
Name Creation Time State
------------------------------------------------------------
kvm107-snap 2020-05-30 18:23:53 +0800 running
4、查看指定虚拟机信息
[root@localhost ~]# qemu-img info /home/vms/kvm107.qcow2
image: /home/vms/kvm107.qcow2
file format: qcow2
virtual size: 25G (26843545600 bytes)
disk size: 4.0G
cluster_size: 65536
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 kvm107-snap 401M 2020-05-30 18:23:53 00:29:35.908
Format specific information:
compat: 1.1
lazy refcounts: true
5、查看指定虚拟机快照文件位置
[root@localhost ~]# ll -h /var/lib/libvirt/qemu/snapshot/kvm107/
total 8.0K
-rw------- 1 root root 4.4K May 30 18:23 kvm107-snap.xml
6、恢复指定虚拟机快照
# 关闭虚拟机
[root@localhost ~]# virsh shutdown kvm107
# 恢复快照
[root@localhost ~]# virsh snapshot-revert kvm107 kvm107-snap
7、删除指定虚拟机快照
[root@localhost ~]# virsh snapshot-delete kvm107 kvm107-snap
Domain snapshot kvm107-snap deleted
标签:快照,虚拟机,KVM,kvm107,snapshot,root,localhost From: https://blog.51cto.com/u_14508118/5857667