Enable sparse image upload
When you use Red Hat Ceph Storage RADOS Block Device (RBD) as the storage back end for the Image service (glance), you can use sparse image upload to reduce network traffic and storage space. With a sparse image file, the Image service can use offsets instead of writing null byte sequences.
Before you begin
- Your Red Hat OpenStack Services on OpenShift (RHOSO) deployment uses Ceph Storage RBD as the storage back end for the Image service.
Procedure
Results
You can import an image and check its size to verify sparse image upload.
- Download the image file locally:
$ wget <file_location>/<file_name>- Replace
<file_location>with the location of the file. - Replace
<file_name>with the name of the file.For example:
$ wget https://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud-1508.qcow2
- Replace
- Check the disk size and the virtual size of the image to be uploaded:
$ qemu-img info <file_name>For example:
$ qemu-img info CentOS-6-x86_64-GenericCloud-1508.qcow2 image: CentOS-6-x86_64-GenericCloud-1508.qcow2 file format: qcow2 virtual size: 8 GiB (8589934592 bytes) disk size: 1.09 GiB cluster_size: 65536 Format specific information: compat: 0.10 refcount bits: 1 - Import the image:
$ glance image-create-via-import --disk-format qcow2 --container-format bare --name centos_1 --file <file_name> - Record the image ID. It is required in a subsequent step.
- Verify that the image is imported and in an active state:
- Access the remote shell for the
OpenStackClientpod from your workstation:$ oc rsh -n openstack openstackclient - View the image:
$ openstack image show <image_id> - Exit the openstackclient pod:
$ exit
- Access the remote shell for the
- From a Ceph Storage node, verify that the size of the image is less than the virtual size from the output of step 2:
$ sudo rbd -p images diff <image_id> | awk '{ SUM += $2 } END { print SUM/1024/1024/1024 " GB" }' 1.03906 GB