一、查看现有磁盘镜像格式与转换

查看磁盘格式

[root@localhost ~]# qemu-img info /var/lib/libvirt/images/centos7.img
image: /var/lib/libvirt/images/centos7.img
file format: raw
virtual size: .0G ( bytes)
disk size: .0G

安装电源服务

# yum install acpid -y

关闭虚拟机

#virsh shutdown centos7

转换磁盘格式

# qemu-img convert -f raw -O qcow2 /var/lib/libvirt/images/centos7.img /var/lib/libvirt/images/centos7.qcow2

-f-------源镜像的格式

-O-----目标镜像的格式

查看转换后的磁盘大小

[root@localhost ~]# du -sh /var/lib/libvirt/images/centos7.qcow2
.4G /var/lib/libvirt/images/centos7.qcow2

查看转换后的磁盘格式

[root@localhost ~]# qemu-img info /var/lib/libvirt/images/centos7.qcow2
image: /var/lib/libvirt/images/centos7.qcow2
file format: qcow2
virtual size: .0G ( bytes)
disk size: .4G
cluster_size:

二、修改虚拟机配置文件

修改磁盘格式

# virsh edit centos7

 <disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/var/lib/libvirt/images/centos7.qcow2'/>
<target dev='hda' bus='ide'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='' bus='' target='' unit=''/>
</disk>

三、对虚拟机进行快照管理

创建centos7虚拟机快照

注意:需要修改磁盘格式

[root@localhost ~]# virsh snapshot-create-as centos7 centos7_snaphshot
Domain snapshot centos7_snaphshot created
[root@localhost ~]#

查看虚拟机镜像快照的版本

# virsh snapshot-list centos7

查看当前虚拟机镜像快照的版本

可以看到为当前最新的快照版本

[root@localhost ~]# virsh snapshot-current centos7
<domainsnapshot>
<name>centos7_snaphshot</name>
<state>shutoff</state>
<creationTime>1547653724</creationTime>
<memory snapshot='no'/>
<disks>
<disk name='hda' snapshot='internal'/>
<disk name='hdc' snapshot='no'/>
</disks>
<domain type='kvm'>
<name>centos7</name>
<uuid>92827f3a-d304-dc83-5ad1-d62f2a755ca3</uuid>
<memory unit='KiB'></memory>
<currentMemory unit='KiB'></currentMemory>
<vcpu placement='static'></vcpu>
<os>
<type arch='x86_64' machine='rhel6.5.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/var/lib/libvirt/images/centos7.qcow2'/>
<target dev='hda' bus='ide'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='' bus='' target='' unit=''/>
</disk>
<controller type='ide' index=''>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='usb' index=''/>
<interface type='network'>
<mac address='52:54:00:07:f7:16'/>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port=''/>
</serial>
<console type='pty'>
<target type='serial' port=''/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
<sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='' heads=''/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
</domain>
</domainsnapshot>

查看快照

# virsh snapshot-info centos7 centos7_snaphshot

四、恢复虚拟机快照

1、恢复虚拟机快照必须关闭虚拟机

查看虚拟机是否是关闭状态

# virsh domstate centos7

确认需要恢复的快照时间,恢复到centos7_snaphshot

# virsh snapshot-list centos7

3、执行恢复并确认恢复版本

# virsh snapshot-revert centos7 centos7_snaphshot

查看当前虚拟机镜像快照的版本

[root@localhost ~]# virsh snapshot-current centos7
<domainsnapshot>
<name>centos7_snaphshot</name>
<state>shutoff</state>
<creationTime></creationTime>
<memory snapshot='no'/>
<disks>
<disk name='hda' snapshot='internal'/>
<disk name='hdc' snapshot='no'/>
</disks>
<domain type='kvm'>
<name>centos7</name>
<uuid>92827f3a-d304-dc83-5ad1-d62f2a755ca3</uuid>
<memory unit='KiB'></memory>
<currentMemory unit='KiB'></currentMemory>
<vcpu placement='static'></vcpu>
<os>
<type arch='x86_64' machine='rhel6.5.0'>hvm</type>
<boot dev='hd'/>
</os>

五、 删除虚拟机快照

1、查看虚拟机快照

# qemu-img info /var/lib/libvirt/images/centos7.qcow2

2、删除快照

# virsh snapshot-delete centos7 centos7_snaphshot

# virsh snapshot-delete centos7 centos7_snaphshot

centos6.5虚拟机快照技术的更多相关文章

  1. vmware vSphere克隆与快照技术

    通过Web vCenter我们可以很容易的对虚拟机进行管理,通过克隆技术或创建模板,我们可以迅速的创建虚拟机,我们也可以通过快照技术去捕获虚拟机的一些状态,比如说虚拟机的内存.设置或者虚拟磁盘的情况等 ...

  2. KVM虚拟机快照链创建,合并,删除及回滚研究

    1 QEMU,KVM,libvirt关系 QEMU QEMU提供了一个开源的服务器全虚拟化解决方案,它可以使你在特定平台的物理机上模拟出其它平台的处理器,比如在X86 CPU上虚拟出Power的CPU ...

  3. 再谈 COW、ROW 快照技术

    目录 目录 前言 快照与备份的区别 快照技术 增量快照之 COW 增量快照之 row 前言 在经过了一段时间的实践之后,再次回顾 COW/ROW 快照技术的实现原理,温故而知新. 快照与备份的区别 传 ...

  4. Redhat6.x下如何制作虚拟机快照和镜像封装

    一.虚拟机快照 1.确认你的物理机上的vg还有足够的剩余空间 [root@hacker ~]# vgs  VG        #PV #LV #SN Attr   VSize  VFree   vg_ ...

  5. centos6.6 虚拟机集群搭建

    1.centosos6.6下载 windows 64位: thunder://QUFodHRwOi8vbGludXguemh1YW5neGl0b25nLmNvbTo4MDgvMjAxNTAxL0Nlb ...

  6. 分布式存储 CentOS6.5虚拟机环境搭建FastDFS-5.0.5集群(转载-2)

    原文:http://www.cnblogs.com/PurpleDream/p/4510279.html 分布式存储 CentOS6.5虚拟机环境搭建FastDFS-5.0.5集群 前言:       ...

  7. vmware克隆Centos6.7虚拟机网卡无法启动问题

    快速处理办法: cat /etc/sysconfig/network-scripts/ifcfg-eth0 sed -i '/UUID/d' /etc/sysconfig/network-script ...

  8. kvm+libvirt虚拟机快照浅析[转]

    浅析snapshots, blockcommit,blockpull 作者:Kashyap Chamarthy <kchamart#redhat.com> Date: Tue, 23 Oc ...

  9. centos6.5虚拟机无法访问外网解决办法

    安装了centos6.5虚拟机,使用的是桥接方式.把所有的配置已经写到/etc/sysconfig/network-scripts/ifcfg-eth0中后,发现内网可以ping通,外网却无法访问. ...

随机推荐

  1. String、StringBuffer、StringBuidler 知识整理

    String.StringBuffer.StringBuidler.这三个家伙,大家都不陌生,肯定也都会用.三者异同大家都能说出来,但是其根本原因是什么呢?带着下面问题,学习一下. 第一.String ...

  2. 浅谈malloc()和free()工作原理

    编程之路刚刚开始,错误难免,希望大家能够指出.  malloc()和free()是我经常需要用到的函数,一般情况下,C程序使用malloc()在堆上分配内存,free()释放内存,两者的参数和返回值就 ...

  3. centos7升级Python版本后,yum不能正常使用

    python升级方法,使用源码编译安装即可,prefix=/usr/local/bin/python3 执行yum list,提示/usr/bin/yum 报错 我是直接在Python2.7的基础上又 ...

  4. Scala之偏函数Partial Function

    https://blog.csdn.net/bluishglc/article/details/50995939 从使用case语句构造匿名函数谈起在Scala里,我们可以使用case语句来创建一个匿 ...

  5. Module Sources

    转自:https://www.terraform.io/docs/modules/sources.html 主要记录module source 的格式 The source argument in a ...

  6. C# to IL 8 Methods(方法)

    The code of a data type is implemented by a method, which is executed by the ExecutionEngine. The CL ...

  7. 编写一个函数 reverse_string(char * string)实现:将参数字符串中的字符反向排列 。(递归实现)

    要求:不能使用C函数库中的字符串操作函数. 思路:在递归函数的调用时,先应该定义一个指针型char字符串.函数内部应先调用自己,在打印,这样才能保证字符串是从最后一个开始输出. #include< ...

  8. 原码,反码,补码,及Java中数字表示方法

    原码:原码是符号位加上真值的绝对值, 即用第一位表示符号, 其余位表示值. 如:如果是八位二进制1即用00000001表示,-1即用10000001表示. 反码:正数的反码就是其本身,负数的反码是在其 ...

  9. laravel 获取上一条insert语句产生的id

    <?php //頭部引入DB類 use Illuminate\Support\Facades\DB; //在方法中獲取获取上一条insert语句产生的id $id = DB::getPdo()- ...

  10. jupyter notebook的路径

    跟你执行jupyter notebook的当前路径有关系:你在哪个路径下执行的这个语句,那么你就是以那个路径为基础的workspace