首页 技术 正文
技术 2022年11月7日
0 收藏 595 点赞 353 浏览 3031 个字

Kvm快照:

1、基于lvm的快照

2、kvm自带的快照功能(需要qcow2 磁盘文件才支持快照)

关闭kvm虚拟机:

查看磁盘文件信息:

[root@super67 ~]# qemu-img info /var/lib/libvirt/images/ubuntu16-1.img

image: /var/lib/libvirt/images/ubuntu16-1.img

file format: raw

virtual size: 0 (0 bytes)

disk size: 0

磁盘格式转换:

[root@super67 ~]# qemu-img convert -f raw -O qcow2 /var/lib/libvirt/images/ubuntu16-1.img /var/lib/libvirt/images/ubuntu16-1.qcow2

查看:

[root@super67 ~]# ll /var/lib/libvirt/images

-rw-r–r– 1 qemu qemu 1485881344 Sep  4 12:47 ubuntu-16.04-desktop-amd64.iso

-rwxr-xr-x 1 root root        107 Sep  4 13:58 ubuntu16-1.img

-rw-r–r– 1 root root     196608 Sep  4 14:11 ubuntu16-1.qcow2

-rw——- 1 root root 8589934592 Sep  4 10:50 www.linux1.cn.img

[root@super67 ~]#  qemu-img info /var/lib/libvirt/images/ubuntu16-1.qcow2

image: /var/lib/libvirt/images/ubuntu16-1.qcow2

file format: qcow2

virtual size: 0 (0 bytes)

disk size: 132K

cluster_size: 65536

编辑ubuntu16-1配置文件:

[root@super67 ~]# virsh edit ubuntu16-1

kvm快照

现在ubuntu16-1虚拟机已经是支持快照的虚拟机了。

接下来进行快照:

[root@super67 ~]# cd /var/lib/libvirt/images

创建快照(名字为ubuntu16-1-copy)

[root@super67 images]# virsh snapshot-create ubuntu16-1

Domain snapshot 1472969993 created

[root@super67 images]# virsh snapshot-create-as ubuntu16-1 ubuntu16-1-copy

Domain snapshot ubuntu16-1-copy created

查看快照版本:

[root@super67 images]# virsh snapshot-list ubuntu16-1

Name                 Creation Time             State

————————————————————

1472969993           2016-09-04 14:19:53 +0800 shutoff

ubuntu16-1-copy      2016-09-04 14:20:53 +0800 shutoff

查看当前快照版本:

[root@super67 images]# virsh snapshot-current ubuntu16-1 |grep “<name>”

<name>ubuntu16-1-copy</name>

<name>1472969993</name>

<name>ubuntu16-1</name>

再次创建快照:

[root@super67 images]# virsh snapshot-create-as ubuntu16-1 ubuntu16-1-copy1

Domain snapshot ubuntu16-1-copy1 created

查看当前版本:

[root@super67 images]# virsh snapshot-current ubuntu16-1 |grep “<name>”

<name>ubuntu16-1-copy1</name>

<name>ubuntu16-1-copy</name>

<name>ubuntu16-1</name>

恢复快照(kvm虚拟机要先关机)

[root@super67 images]# virsh snapshot-revert ubuntu16-1 ubuntu16-1-copy

查看版本:

[root@super67 images]# virsh snapshot-current ubuntu16-1 |grep “<name>”

<name>ubuntu16-1-copy</name>

<name>1472969993</name>

<name>ubuntu16-1</name>

查看快照:

[root@super67 ~]# qemu-img info /var/lib/libvirt/images/ubuntu16-1.qcow2

image: /var/lib/libvirt/images/ubuntu16-1.qcow2

file format: qcow2

virtual size: 0 (0 bytes)

disk size: 144K

cluster_size: 65536

Snapshot list:

ID        TAG                 VM SIZE                DATE       VM CLOCK

1         1472969993                0 2016-09-04 14:19:53   00:00:00.000

2         ubuntu16-1-copy           0 2016-09-04 14:20:53   00:00:00.000

3         ubuntu16-1-copy1          0 2016-09-04 14:25:28   00:00:00.000

删除快照:(用TAG号删)

[root@super67 ~]# virsh snapshot-delete ubuntu16-1 ubuntu16-1-copy1

Domain snapshot ubuntu16-1-copy1 deleted

查看快照:

[root@super67 ~]# qemu-img info /var/lib/libvirt/images/ubuntu16-1.qcow2

image: /var/lib/libvirt/images/ubuntu16-1.qcow2

file format: qcow2

virtual size: 0 (0 bytes)

disk size: 144K

cluster_size: 65536

Snapshot list:

ID        TAG                 VM SIZE                DATE       VM CLOCK

1         1472969993                0 2016-09-04 14:19:53   00:00:00.000

2         ubuntu16-1-copy           0 2016-09-04 14:20:53   00:00:00.000

下一篇: ps插件安装
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,965
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,486
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,331
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,114
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,747
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,782