Nova image create

本文详细介绍了QCOW2磁盘映像格式的特点,包括其优势、创建方法以及在OpenStack环境下的具体应用。通过使用qemu-img命令进行操作,了解如何利用QCOW2实现快速创建瘦装备虚拟机实例,并在OpenStack中实现多个VM共用一个baseimage(backingfile)的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值