OpenStack: import existing Ceph volumes in Cinder

This method can be useful while migrating from one OpenStack to another.

Imagine you have operating system instances configured with a legacy application that can only run once. Imagine that you want to run them in Ceph using Cinder booting from volumes. Then this is probably how you will import them.

  1. If you only need a single instance of that virtual machine then you should not bother to convert it in this first place. No matter the original format, keep it like this. For Ceph RAW is recommended while doing COW clone but not mandatory.
  2. Evaluate the size of your image (du)
  3. Create a Cinder volume with the corresponding size
  4. Get the uuid of the volume
  5. Remove the volume since RBD won’t allow overwrite: rbd -p volumes rm <volume-uuid>
  6. Import the volume with rbd -p volumes --image-format 2 import <your-image-file> <volume-uuid>
  7. Flag the volume as bootable: cinder set-bootable <volume> True
  8. Boot from volume