This section describes what customizations you should to your image to maximize compatibility with OpenStack.
An image needs to be able to retrieve information from OpenStack, such as the ssh public key and user data that the user submitted when requesting the image. This information is accessible via the metadata service or the config drive. The easiest way to support this is to install the cloud-init package into your image.
The size of the disk in a virtual machine image is determined when you initially
create the image. However, OpenStack lets you launch instances with different size
drives by specifying different flavors. For example, if your image was created with a 5 GB disk, and
you launch an instance with a flavor of m1.small, the resulting
virtual machine instance will have a primary disk of 10GB. When an instance's disk
is resized up, zeros are just added to the end.
Your image needs to be able to resize its partitions on boot to match the size requested by the user. Otherwise, after the instance boots, you will need to manually resize the partitions if you want to access the additional storage you have access to when the disk size associated with the flavor exceeds the disk size your image was created with.
Your image must be configured to deal with two issues:
The image's partition table describes the original size of the image
The image's filesystem fills the original size of the image
Your image will need to run a script on boot to
modify the partition table. Due to a limitation in
the Linux kernel, you cannot modify a partition
table of a disk that has partition currently
mounted (you can for LVM, but not for "raw
disks"); this partition adjustment has to happen
inside the initramfs before the root volume is
mounted, or a reboot has to be done to free the
mount of /.
Ubuntu cloud images and cirros images use a tool called growpart that is part of the cloud-utils package.
You will need to resize the file system in addition to the partition table. If you have cloud-init installed, it will do the resize assuming the partition tables have been adjusted properly. Cirros images run resize2fs on the root partition on boot.
![]() | Note |
|---|---|
If you are using XenServer as your hypervisor, the above steps are not needed as the Compute service will automatically adjust the partition and filesystem for your instance on boot. Automatic resize will occur if the following are all true:
|

![[Note]](../common/images/admon/note.png)
