码迷,mamicode.com
首页 > 其他好文 > 详细

kvm初体验之九:vm创建快照

时间:2015-06-05 08:44:51      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

1. 准备一个磁盘格式为qcow2vmraw格式的磁盘无法创建快照)

方法一:从头安装一个磁盘格式为qcow2vm

[root@tanghuimin vm]# qemu-img create -f qcow2 -o preallocation=metadata /vm/vm2.qcow2 2G

Formatting ‘/vm/vm2.qcow2‘, fmt=qcow2 size=2147483648 encryption=off cluster_size=65536 preallocation=‘metadata‘

[root@tanghuimin vm]# qemu-img info vm2.qcow2

image: vm2.qcow2

file format: qcow2

virtual size: 2.0G (2147483648 bytes)

disk size: 464K

cluster_size: 65536


virt-install --name vm2 --vcpus=1 --ram=1024 --disk path=/vm/vm2.qcow2,format=qcow2 --cdrom /root/iso/CentOS-6.6-x86_64-minimal.iso --network bridge:br0


方法二:将现存的磁盘格式为rawvm转换成qcow2的磁盘格式

[root@tanghuimin vm]# qemu-img info vm1-clone

image: vm1-clone

file format: raw

virtual size: 2.0G (2147483648 bytes)

disk size: 2.0G


[root@tanghuimin vm]# qemu-img convert -f raw vm1-clone -O qcow2 vm1-clone.qcow2

[root@tanghuimin vm]# qemu-img info vm1-clone.qcow2

image: vm1-clone.qcow2

file format: qcow2

virtual size: 2.0G (2147483648 bytes)

disk size: 813M

cluster_size: 65536


virsh edit vm1-clone

<disk type=‘file‘ device=‘disk‘>

<driver name=‘qemu‘ type=‘raw‘ cache=‘none‘/>

<source file=‘/vm/vm1-clone‘/>

<target dev=‘hda‘ bus=‘ide‘/>

<address type=‘drive‘ controller=‘0‘ bus=‘0‘ target=‘0‘ unit=‘0‘/>

</disk>

修改为

<disk type=‘file‘ device=‘disk‘>

<driver name=‘qemu‘ type=‘qcow2‘ cache=‘none‘/>

<source file=‘/vm/vm1-clone.qcow2‘/>

<target dev=‘hda‘ bus=‘ide‘/>

<address type=‘drive‘ controller=‘0‘ bus=‘0‘ target=‘0‘ unit=‘0‘/>

</disk>


2. 创建快照(virsh snapshot-create

virsh # snapshot-list vm2

Name Creation Time State

------------------------------------------------------------


virsh # snapshot-create vm2

Domain snapshot 1433458417 created

virsh #

virsh # snapshot-list vm2

Name Creation Time State

------------------------------------------------------------

1433458417 2015-06-05 06:53:37 +0800 shutoff



3. 从快照恢复(virsh snapshot-revert

virsh # snapshot-list vm2

Name Creation Time State

------------------------------------------------------------

1433458417 2015-06-05 06:53:37 +0800 shutoff

 

virsh # snapshot-revert vm2 1433458417


4. 删除快照(virsh snapshot-delete

virsh # snapshot-list vm2

Name Creation Time State

------------------------------------------------------------

1433458417 2015-06-05 06:53:37 +0800 shutoff

 

virsh #

virsh # snapshot-delete vm2 1433458417

Domain snapshot 1433458417 deleted

 

virsh # snapshot-list vm2

Name Creation Time State

------------------------------------------------------------

 


kvm初体验之九:vm创建快照

标签:

原文地址:http://www.cnblogs.com/tanghuimin0713/p/4553663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!