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

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


  • 相关阅读:
    Redis-持久化
    Redis-Sort命令
    Redis-ZSet常用命令
    Redis-Hash
    Redis-Set常用命令
    Redis-List常用命令
    Redis-String常用命令
    访问控制
    c++之旅:多态
    c++之旅:类型的强制转换
  • 原文地址:https://www.cnblogs.com/tanghuimin0713/p/4553663.html
Copyright © 2011-2022 走看看