OpenStack Add Images to Glance

Glance is the OpenStack image service. It stores virtual machine images that Nova uses to boot instances. This guide covers uploading, managing, and optimizing images in Glance on OpenStack 2024.2 Dalmatian.

Supported Image Formats

Format Extension Best For
raw .img Ceph RBD backends (no conversion needed)
qcow2 .qcow2 Local storage, thin provisioning
vmdk .vmdk VMware migrations
iso .iso CD/DVD boot images
aki/ari/ami varies Legacy Amazon-style images

Prerequisites

  • OpenStack 2024.2 Dalmatian with Glance running
  • Admin or member credentials sourced
  • Image files downloaded locally

Step 1: Download Cloud Images

Most Linux distributions provide optimized cloud images:

# Ubuntu 22.04
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img

# Rocky Linux 9
wget https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud.latest.x86_64.qcow2

# Debian 12
wget https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2

# CirrOS (tiny test image)
wget https://download.cirros-cloud.net/0.6.2/cirros-0.6.2-x86_64-disk.img

Step 2: Upload an Image

Basic upload:

openstack image create \
  --disk-format qcow2 \
  --container-format bare \
  --public \
  --file jammy-server-cloudimg-amd64.img \
  "Ubuntu 22.04"

Key parameters:

Parameter Description
--disk-format Image format: raw, qcow2, vmdk, iso
--container-format Usually bare (use ami for Amazon-style)
--public Visible to all projects (admin only)
--private Visible only to the uploading project
--file Local path to the image file

Step 3: Upload a Raw Image for Ceph

If your Glance backend is Ceph RBD, raw format avoids conversion overhead:

# Convert qcow2 to raw
qemu-img convert -f qcow2 -O raw jammy-server-cloudimg-amd64.img jammy.raw

# Upload as raw
openstack image create \
  --disk-format raw \
  --container-format bare \
  --public \
  --file jammy.raw \
  "Ubuntu 22.04 (raw)"

Step 4: Upload via URL (Web Download)

Glance can fetch images from a URL directly:

openstack image create \
  --disk-format qcow2 \
  --container-format bare \
  --public \
  --uri https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img \
  "Ubuntu 22.04 (web)"

This requires the web-download import method to be enabled in Glance.

Step 5: Set Image Properties

Add metadata to help Nova schedule and configure instances:

openstack image set \
  --property hw_scsi_model=virtio-scsi \
  --property hw_disk_bus=scsi \
  --property hw_qemu_guest_agent=yes \
  --property os_type=linux \
  --property os_distro=ubuntu \
  --property os_version=22.04 \
  --min-disk 10 \
  --min-ram 512 \
  "Ubuntu 22.04"

Important properties:

Property Purpose
hw_disk_bus Disk bus type: virtio, scsi, ide
hw_vif_model NIC type: virtio, e1000
hw_qemu_guest_agent Enable QEMU guest agent
os_distro OS distribution (used by Horizon)
--min-disk Minimum root disk size in GB
--min-ram Minimum RAM in MB

Step 6: Manage Images

List all images:

openstack image list
openstack image list --public
openstack image list --long

Show image details:

openstack image show "Ubuntu 22.04"

Delete an image:

openstack image delete "Ubuntu 22.04"

Share a private image with another project:

openstack image add project "Ubuntu 22.04" <project-id>
# The target project must accept:
openstack image set --accept "Ubuntu 22.04"

Step 7: Create Images from Running Instances

Snapshot a running VM to create a new image:

openstack server image create --name "web-server-snapshot" my-vm
openstack image list  # snapshot appears here

Best Practices

Practice Reason
Use raw format with Ceph Avoids qcow2-to-raw conversion on every boot
Set min-disk and min-ram Prevents boot failures from undersized flavors
Add os_distro metadata Enables Horizon to show correct OS icons
Use virtio disk and NIC Best performance for Linux guests
Regularly update images Keep security patches current

Troubleshooting

Issue Fix
Upload hangs Check Glance API logs and backend storage space
Image stuck in queued Glance backend may be misconfigured
VM fails to boot from image Verify disk format matches actual file format
Permission denied Check image visibility and project membership

Summary

Glance image management is foundational to OpenStack operations. Upload optimized cloud images in the right format for your storage backend, set meaningful metadata, and keep images updated for security.