CLI Client: Volumes

This page describes how to use the Openstack CLI client to manage your volumes.

List Volumes

openstack volume list

List all volumes in the project.

Available filters:

  • --status <status>: List only volumes with the specified status. For example, openstack volume list --status available lists only available volumes that are ready to be attached to an instance.

Create a Volume

openstack volume create --size <size-in-GiB> <new-volume-name>
openstack volume create --snapshot <snapshot-name-or-id> <new-volume-name>
openstack volume create --source <volume-name-or-id> <new-volume-name>
openstack volume create --image <image-name-or-id> <new-volume-name>

There are four ways to create a new volume:

  • --size: Create an empty volume of the specified size in GB.
  • --snapshot: Create a volume from the specified volume snapshot. This option can be used in combination with the --size option to create a volume larger than the source snapshot.
  • --source: Create a volume by cloning the specified volume. This option can be used in combination with the --size option to create a volume larger than the source volume.
  • --image: Create a volume from the specified image. This option can be used in combination with the --size option to create a volume larger than the source image.

Additional option:

  • --description <volume-description>: Add additional volume description.

Delete a Volume

openstack volume delete <volume-name-or-id>

Attach a Volume to an Instance

openstack server add volume <instance-name-or-id> <volume-name-or-id>

Attach the volume to the specified instance.

Available options:

  • --enable-delete-on-termination: Delete the volume when the instance is deleted.
  • --disable-delete-on-termination: (default) Keep the volume when the instance is deleted.

Detach a Volume from an Instance

openstack server remove volume <instance-name-or-id> <volume-name-or-id>

Extend a Volume

openstack volume set --size <size-in-GiB> <volume-name-or-id>

The new size should be larger than the existing size. The volume must be in the available state (i.e. detached from an instance) to be extended.

List Snapshots

openstack volume snapshot list

Take a Volume Snapshot

openstack volume snapshot create --volume <volume-name-or-id> <new-snapshot-name>

Delete a Snapshot

openstack volume snapshot delete <snapshot-name-or-id>

Transfer a Volume to a Different Project

See the Transfer a Volume to a Different Project section of the Storage page on how to transfer a volume from one project to another.

Create a Transfer Request

openstack volume transfer request create <volume-name-or-id>

Accept a Transfer Request

openstack volume transfer request accept --auth-key <key> <transfer-request-id>