Nova image create

来源:互联网 发布:淘宝网站经营管理 编辑:程序博客网 时间:2024/06/15 20:00

QCOW2 (qemu copy-on-write)                                                      

Is one of the disk image formats supported by the QEMUprocessor emulator. It is a representation of a fixed size block device in afile. Benefits it offers over using raw dump representation include:

      1.    Smaller file size, even on filesystems whichdon't support holes (i.e. sparse files)

      2.    Copy-on-write support, where the image onlyrepresents changes made to an underlying disk image

      3.    Snapshot support, where the image can containmultiple snapshots of the images history

      4.    Optional zlib based compression

      5.    Optional AES encryption

The qemu-img command is the most common way of manipulatingthese images e.g.

  $> qemu-imgcreate -f qcow2 test.qcow2 4G

  Formating'test.qcow2', fmt=qcow2, size=4194304 kB

  $> qemu-imgconvert test.qcow2 -O raw test.img


QCOW2 backing files and overlays                                                   

qcow2(qemu copy-on-write)具有创建一个base-image,以及在base-image(即backingfile)

的基础上创建多个copy-on-write overlays镜像(image)的能力.backingfiles和overlays十分有用,可以迅速的创建瘦装备虚拟机的实例,特别是在开发测试的时候可以迅速的回滚到之前的某个已知状态,丢弃overlay.如图1所示,Base_image是Snap_1的backingfile,反过来Snap_1是Base_image的overlay。


QCOW2Openstack中的实际应用                                                

多个VM的root disk image是基于同一个base image (backing file),公共的base image为只读的。


nova image-create                                                               

Create a new image by taking a snapshot of a running server (VM instance), and upload the newimage file to Glance.

Step1: create imagebased on Base_image:  “/var/lib/nova/instances/

_base/020496fa009f00d1b1d69de8d42222b56afd9ec8”

# qemu-img create  -fqcow2 backing_file=’/var/lib/nova/instances/_base/

 020496fa009f00d1b1d69de8d42222b56afd9ec8’/var/lib/nova/instances/snapshots/tmpOEeP4A/2bf3a7f8d7094360824b9e14f2f48338

Step2: blockRebase cannotbe executed on persistent domains, so we need to temporarily undefine it. domain.undefine().

Step3: blockRebase();pull the entire source chain into the destination file ‘New_image(v1)’ .

Step4: convert format

# qemu-img convert -f qcow2 -O qcow2 -s 2bf3a7f8d7094360824b9e14f2f48338/var/lib/nova/instances/7bf40411-88ac-43d1-8e38-382d8af1915b/disk/var/lib/nova/instances/snapshots/tmpOEeP4A/2bf3a7f8d7094360824b9e14f2f48338

Step5: Upload toGlance




0 0
原创粉丝点击