zoukankan      html  css  js  c++  java
  • kvm初体验之九:vm创建快照

    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

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


  • 相关阅读:
    随手记十——淘宝静态页面
    随手记九——溢出文字处理、背景图片填充、图片代替文字
    随手记八——关于伪元素和仿淘宝导航栏
    随手记七——关于float的一个上节没明白的问题
    随手记六——两个经典BUG和bfc
    随手记五——盒子模型和层模型
    随手记四——一些课堂笔记和小技巧、总结
    随手记三——理解相邻兄弟选择器的辛酸过程
    随手记二——CSS样式和选择器
    jQuery实现手风琴效果
  • 原文地址:https://www.cnblogs.com/tanghuimin0713/p/4553663.html
Copyright © 2011-2022 走看看