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
# 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
Attach/detach volume to an instance
Attach/detach your volume to a server, specifying the server name/ID and the volume name/ID
# 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 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
# 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
# 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>