A volume is a detachable block storage device, similar to a USB hard drive. You can attach a volume to only one instance. Use the openstack client commands to create and manage volumes.

Create a volume

To create a volume, use

Create volume
# Optionally, you can create a volume from an image, snapshot, or other volume
$ openstack volume create --size <size_in_GB> <name> [--image <image> | --snapshot <snapshot> | --source <volume>]

Check that the volume just created has been created with the usual commands

Volume details
$ openstack volume list
+--------------------------------------+-------+-----------+------+-------------+
| ID                                   | Name  | Status    | Size | Attached to |
+--------------------------------------+-------+-----------+------+-------------+
| e8d1b256-b3bd-4663-b544-54950397d0a2 | test2 | available |    2 |             |
| a964197f-2622-489c-bf62-40752fd0f737 | test1 | available |    1 |             |
+--------------------------------------+-------+-----------+------+-------------+
$ openstack volume show <volume>
+------------------------------+--------------------------------------+
| Field                        | Value                                |
+------------------------------+--------------------------------------+
| attachments                  | []                                   |
| availability_zone            | nova                                 |
| bootable                     | false                                |
| consistencygroup_id          | None                                 |
| created_at                   | 2022-05-04T14:22:19.000000           |
| description                  |                                      |
| encrypted                    | False                                |
| id                           | a964197f-2622-489c-bf62-40752fd0f737 |
| multiattach                  | False                                |
| name                         | test1                                |
| os-vol-tenant-attr:tenant_id | d2b42ee4145849819b41a9d8794a932f     |
| properties                   |                                      |
| replication_status           | None                                 |
| size                         | 1                                    |
| snapshot_id                  | None                                 |
| source_volid                 | None                                 |
| status                       | available                            |
| type                         | default                              |
| updated_at                   | 2022-05-04T14:22:19.000000           |
| user_id                      | 2adacadc9d1c4631b38e4f1135ac24e4     |
+------------------------------+--------------------------------------+

Attach/detach volume to an instance

Attach/detach your volume to a server, specifying the server name/ID and the volume name/ID

Attach/detach volume
# After running the following command, check the volume status with "openstack volume show"
$ openstack server add volume <server> <volume>
$ openstack server remove volume <server> <volume>

Resize/delete a volume

To resize/delete your volume, you must first detach it from the server

Resize volume
# Resize the volume by passing the volume name/ID and the new size (a value greater than the old one) as parameters
$ openstack volume set <volume> --size <size>
# When the volume is fully deleted, it disappears from the list of volumes
$ openstack volume delete <volume>

Transfer a volume

You can transfer a volume from one owner to another. The volume donor, or original owner, creates a transfer request and sends the created transfer ID and authorization key to the volume recipient. The volume recipient, or new owner, accepts the transfer by using the ID and key.

As the volume donor, request a volume transfer authorization code for a specific volume

Donor a volume
# The auth_key will not be available later, so you must capture it now or else you will be unable to use the transfer.
$ openstack volume transfer request create <volume>
+------------+--------------------------------------+
| Field      | Value                                |
+------------+--------------------------------------+
| auth_key   | a039eefed1443cda                     |
| created_at | 2022-05-04T17:10:53.343095           |
| id         | 9bdfbd11-0253-4c13-af3e-14ad3f35b25f |
| name       | None                                 |
| volume_id  | e8d1b256-b3bd-4663-b544-54950397d0a2 |
+------------+--------------------------------------+

The volume must be in an available state or the request will be denied. If the transfer request is valid in the database (that is, it has not expired or been deleted), the volume is placed in an awaiting-transfer state. As the volume recipient, you must first obtain the transfer ID and authorization key from the original owner. Then, accept (or delete) the request

Receive a volume
# If you do not have a sufficient quota for the transfer, the transfer is refused.
$ openstack volume transfer request accept --auth-key <key> <transfer-request-id>

$ openstack volume transfer request delete <transfer-request-id>

# To verify the correct outcome of the transfer or, in general, to get more details
$ openstack volume transfer request list
$ $ openstack volume transfer request show <transfer-request-id>
  • No labels