Previous article Ceph and OpenStack – Best Practices Part I, and this time we will continue from the previous recommendations to further elaborate on several best practices for integrating Ceph and OpenStack. These configurations can enable even more seamless integration between OpenStack and Ceph.
Table of Contents
Using RAW Image
Previous article Ceph and OpenStack – Best Practices Part I In the previous article, we briefly introduced the RBD layering feature, although this capability comes with certain limitations. Since OpenStack requires images to be in RAW format to leverage RBD layering, we recommend converting all uploaded images into RAW format first. The qemu-img command makes it easy to convert between various formats:
qemu-img convert image.qcow2 image.raw
Once the image is uploaded to OpenStack in RAW format, it will then utilize the RBD layering feature.
Setting image to make VM use Virtio-SCSI
Regardless of whether it's ephemeral disk or volumes, the Nova VM using RBD backend defaults to using the Virtio-blk driver to allow the guest to access the RBD image. At this point, VirtIO provides a paravirtual I/O bus, and the devices are named as /dev/vda, /dev/vdb, and so on. The VirtIO block device offers low latency and high efficiency, but it does not support the discard command.
The lack of discard support means that guests cannot use the discard option when unmounting disks, nor can the system use fstrim to clean up already freed blocks. This creates security risks because data that users intend to delete may not actually be removed or overwritten.
Not supporting discard also means that RBD images' underlying RADOS objects will not be deleted throughout the image's lifetime — they will remain stored until the entire image is deleted. As a result, the Ceph cluster may contain hundreds of thousands of RADOS objects that are never reused.
Fortunately, another VirtIO disk driver supports the discard command — the VirtIO SCSI controller, known as virtio-scsi.
To use the VirtIO SCSI controller in OpenStack, you need to configure certain properties in Glance images, specifically setting hw_scsi_model and hw_disk_bus. These can be easily configured via OpenStack CLI commands:
openstack image set
--property hw_scsi_model=virtio-scsi
--property hw_disk_bus=scsi
<image 的名稱或 ID>
Or, if you have multiple images, you can use a simple script:
for i in $(openstack image list | awk '{print