I am trying to figure out the path of least resistance in OpenStack to get from a live CD to a disk image that can be used for deploying new guest instances.

If you boot an OpenStack instance from a live CD, you can install an OS onto the "ephemeral" disk (which will, in this case, be /dev/vda)...

...that's great, but there's no way to create an image from that disk; the image-create command will attempt (and fail) to snapshot the live CD itself (because this is the boot volume).

You can create and attach a new volume (using volume-create and volume-attach) and then install the OS on that, but there's doesn't appear to be any way to convert this volume into a Glance-hosted image for use by other instances.

As an administrator I can obviously log in to the storage host and create a new glance image directly from the volume block device, but this isn't an avenue available to anyone interacting via the API or web GUI.

Are there any other options available?

4 Answers 4


In Icehouse and later you can convert Cinder volume to Glance image with upload-to-image command:

cinder upload-to-image <volume> <image-name>

I've successfully built images for openstack using KVM on my local linux machine using a local disk image file (raw or qcow2), converted the image file to a compressed qcow2, and uploaded that with glance.

Some tips:

  1. you'll need cloud-init or an /etc/rc.local script or similar to fetch the instance metadata (ssh keys, IP address, hostname, userdata, etc) from and configure the VM with it.

    cloud-init works best on ubuntu, but has been ported to Debian, and I've even seen a port for RH.

  2. Cleaning up the image (erasing logs and shell history, disabling passwords, deleting /etc/udev/rules.d/70-persistent-net.rules, and so on) and zero-filling the disk image before making a compressed qcow2 to upload is a good idea. You can quite easily shrink a VM image with a 10GB disk to 300-500MB, which is faster to upload and faster to copy when openstack launches an instance.

The simplest way to zerofill the disk is something like 'dd if=/dev/zero of=/root/junk ; rm -f /root/junk'. Alternatively, you can shutdown the VM, loopback mount it (you can use qemu-nbd if the image is already a qcow2), and then zerofill it. If the filesystem is ext2/3/4 you can use a tool called zerofree to zerofill it (must be unmounted or mounted RO). If it's some other fs you could use sfill from secure-delete (secure-delete's home page has vanished).

BTW, even if your 'source' image is already compressed qcow2, it's still worthwhile 'converting' it to a fresh compressed qcow2 before uploading. That gets rid of the old data left behind when a file is copied-on-write.


Simple way to convert cinder volume to glance image convert LVM partition to qcow2 format with qemu-img.


sudo qemu-img convert -c -f raw -O qcow2 /dev/stack-volumes/volume-6e4eb1d5-71fa-45a1-9178-ac6611351404 test.img

Next step add image to glance:

glance image-create --name test_converted --disk-format qcow2 --container-format bare < test.img
  • This would be the "As an administrator I can obviously log in to the storage host and create a new glance image directly from the volume block device..." solution I was referring to in my question.
    – larsks
    Feb 24, 2013 at 3:22

This is an old question, but what you want to do is use kvm to make a raw disk image using the cdrom iso file and an empty volume. Then, you can upload the raw disk to glance and use it to boot others.

This is how you make a base Debian, Ubuntu or other linux host, for example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.