0%

Shrink the image to support smaller flavor

When snapshot an instance to get an image, the snapshot will keep the flavor information in the image. Then this image will require the disk size in the flavor for the new instance to be larger than the flavor info in the image. This kind of disk requirement is called “virtual disk”. To shrink the “virtual disk”, the following method has been tested and proves to be useful:

  1. Download the snapshot image from Glance as a raw image

  2. Resize the image size using virt-sparsify

  3. Convert the resized image to the raw format

    1
    qemu-img convert -f qcow2 -O raw ***.qcow2 ***.raw
  4. Check the virtual disk size

    1
    qemu-img info ***.raw