In this article we describe some of the common commands used for cinder volume configuration such as creating volumes, deleting volumes etc. Prior to using the command line examples you would need to source the required environment variables as described in http://docs.openstack.org/user-guide-admin/content/cli_openrc.html

Obtaining the list of cinder volumes

cinder list

For example:
# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| f77e0684-0566-46d2-8edb-025b4769a85f | available |   volume1    |  20  |     None    |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

Creating a new cinder volume

cinder create --display_name <display name> <size>

The display name is a name associated with the volume. It does not have to be unique, but assigning a different name to each volume helps in identifying the volumes easily. The size argument specifies the size of the volume in GB

For example:
# cinder create  --display_name volume1 20
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|       bootable      |                false                 |
|      created_at     |      2013-11-25T14:00:02.270869      |
| display_description |                 None                 |
|     display_name    |               volume1                |
|          id         | f77e0684-0566-46d2-8edb-025b4769a85f |
|       metadata      |                  {}                  |
|         size        |                  20                  |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |                 None                 |
+---------------------+--------------------------------------+

If you have created volume types, the type can be passed with the option --volume_type

For example:
# cinder create --volume_type sanvolumes --display_name volume2 20
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|       bootable      |                false                 |
|      created_at     |      2013-11-25T14:05:06.921800      |
| display_description |                 None                 |
|     display_name    |               volume2                |
|          id         | 07f2f6a3-cebf-4e6d-a879-984cf3f02a86 |
|       metadata      |                  {}                  |
|         size        |                  20                  |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |               sanvolumes             |
+---------------------+--------------------------------------+
# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 07f2f6a3-cebf-4e6d-a879-984cf3f02a86 | available |   volume2    |  20  |   sanvolumes|  false   |             |
| f77e0684-0566-46d2-8edb-025b4769a85f | available |   volume1    |  20  |     None    |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

Deleting a volume

cinder delete <ID>

For example:
# cinder delete 07f2f6a3-cebf-4e6d-a879-984cf3f02a86
# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| f77e0684-0566-46d2-8edb-025b4769a85f | available |   volume1    |  20  |     None    |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

Creating a snapshot from a volume

cinder snapshot-create --display-name <snapshot display name> <volume ID>
Similar to the volume displaye name, the snapshot display name is a name given to the snapshot. volume ID is the ID for the volume

For example:
# cinder snapshot-create --display-name snapshot1 f77e0684-0566-46d2-8edb-025b4769a85f
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|      created_at     |      2013-11-25T14:09:10.716971      |
| display_description |                 None                 |
|     display_name    |              snapshot1               |
|          id         | b884a611-257c-45d3-a138-d57c881b992e |
|       metadata      |                  {}                  |
|         size        |                  20                  |
|        status       |               creating               |
|      volume_id      | f77e0684-0566-46d2-8edb-025b4769a85f |
+---------------------+--------------------------------------+

Listing snapshots

cinder snapshot-list

For example:
# cinder snapshot-list
+--------------------------------------+--------------------------------------+----------+--------------+------+
|                  ID                  |              Volume ID               |  Status  | Display Name | Size |
+--------------------------------------+--------------------------------------+----------+--------------+------+
| b884a611-257c-45d3-a138-d57c881b992e | f77e0684-0566-46d2-8edb-025b4769a85f | creating |  snapshot1   |  20  |
+--------------------------------------+--------------------------------------+----------+--------------+------+

Deleting a snaphsot

cinder snapshot-delete <snapshot ID>

For example:
# cinder snapshot-delete b884a611-257c-45d3-a138-d57c881b992e

Attaching a volume to an instance

nova volume-attach <instance ID> <volume ID> <device>

For example:
# nova list
+--------------------------------------+-------+---------+------------------------------------+
| ID                                   | Name  | Status  | Networks                           |
+--------------------------------------+-------+---------+------------------------------------+
| 25e4ccf0-8723-486e-a9f9-99e6008fe7c2 | test2 | SHUTOFF | novanetwork=192.168.32.2, 10.3.4.5 |
+--------------------------------------+-------+---------+------------------------------------+
# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| f77e0684-0566-46d2-8edb-025b4769a85f | available |   volume1    |  20  |     None    |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
# nova volume-attach 25e4ccf0-8723-486e-a9f9-99e6008fe7c2 f77e0684-0566-46d2-8edb-025b4769a85f auto
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| serverId | 25e4ccf0-8723-486e-a9f9-99e6008fe7c2 |
| id       | f77e0684-0566-46d2-8edb-025b4769a85f |
| volumeId | f77e0684-0566-46d2-8edb-025b4769a85f |
+----------+--------------------------------------+
auto specifies that the device (/dev/vdb) path is auto assigned

Detaching a volume from an instance

nova volume-detach <instance ID> <volume ID> <device>

For example:
# nova volume-detach 25e4ccf0-8723-486e-a9f9-99e6008fe7c2 f77e0684-0566-46d2-8edb-025b4769a85f

Complete options for commands

Issuing help on a command will list the complete options for a command

For example:
cinder help create (Lists all options that can be passed for the create command)