Managing Volumes

A volume is a detachable block storage device, similar to a USB hard drive. You can attach a volume to only one instance. To create and manage volumes, you use a combination of nova and cinder client commands.

To create a volume based on an image:

  1. List available images and note the ID of the image to use for your volume.

    $ openstack image list
    | ID           | Name                                  | Status |
    |--------------|---------------------------------------|--------|
    | <image_id>   | Windows10-3                           | active |
    | <image_id>   | ubuntu_1204_server_cloudimg_amd64     | active |
    | <image_id>   | test-my-first-snapshot                | active |
    | <image_id>   | Ubuntu-Server-16.04-CloudImage-raw    | active |
    
    
  2. List availability zones and note the Zone Name of the AZ to create your volume.

    $ openstack availability zone list
    | Zone Name | Zone Status |
    |-----------|-------------|
    | internal  | available   |
    | dev       | available   |
    
  3. Create a volume with 8 gibibytes (GiB) of space; specify the availability zone and image.

    $ openstack volume create <VOLUME_NAME> --size <SIZE> --image <IMAGE_ID> --availability-zone <AZ>
    +---------------------+--------------------------------------+
    | Field               | Value                                |
    +---------------------+--------------------------------------+
    | attachments         | []                                   |
    | availability_zone   | <az_name>                            |
    | bootable            | false                                |
    | consistencygroup_id | None                                 |
    | created_at          | 2017-05-15T19:22:20.562347           |
    | description         | None                                 |
    | encrypted           | False                                |
    | id                  | <volume_id>                          |
    | migration_status    | None                                 |
    | multiattach         | False                                |
    | name                | <volume_name>                        |
    | properties          |                                      |
    | replication_status  | disabled                             |
    | size                | 8                                    |
    | snapshot_id         | None                                 |
    | source_volid        | None                                 |
    | status              | creating                             |
    | type                | ceph                                 |
    | user_id             | <user_id>                            |
    +---------------------+--------------------------------------+
    
    
  4. Verify that your volume was created successfully.

    $ openstack volume list
    | ID           | Display Name    | Status    | Size | Attached to |
    |--------------|-----------------|-----------|------|-------------|
    | <volume_id>  | my-new-volume   | available | 8    |             |
    | <volume_id>  | my-bootable-vol | available | 8    |             |
    

    If your volume was created successfully, its status is available. If its status is error, you may have exceeded your quota.

Creating a Volume from a Specified Volume Type

Note
If the parameters are not set, the Block Storage service uses default_volume_type, which is defined in Metacloud based on your storage configuration: nfs, ceph, or pure.

To create a volume using volume_type:

Add the --volume type paramenter when creating a volume.

$ openstack volume create --name <VOLUME_NAME> --volume-type <VOLUME_TYPE> <SIZE>

To create a volume using a volume_type:

  1. List images and note the ID of the image to use.

    $ openstack image list
    | ID           | Name                               | Status |
    |--------------|------------------------------------|--------|
    | <image_id>   | Windows10-3                        | active |
    | <image_id>   | ubuntu_1204_server_cloudimg_amd64  | active |
    | <image_id>   | test-my-first-snapshot             | active |
    | <image_id>   | Ubuntu-Server-16.04-CloudImage-raw | active |
    
  2. Create the volume.

    $ openstack volume create <VOLUME_NAME> --image <IMAGE_ID> --size <SIZE> --availablilty zone <AZ> --type <VOLUME_TYPE>
    +---------------------+--------------------------------------+
    | Field               | Value                                |
    +---------------------+--------------------------------------+
    | attachments         | []                                   |
    | availability_zone   | stage1                               |
    | bootable            | false                                |
    | consistencygroup_id | None                                 |
    | created_at          | 2017-05-15T20:32:25.386999           |
    | description         | None                                 |
    | encrypted           | False                                |
    | id                  | <volume_id>                          |
    | migration_status    | None                                 |
    | multiattach         | False                                |
    | name                | EXAMPLE1                             |
    | properties          |                                      |
    | replication_status  | disabled                             |
    | size                | 3                                    |
    | snapshot_id         | None                                 |
    | source_volid        | None                                 |
    | status              | creating                             |
    | type                | ceph                                 |
    | user_id             | <user_id>                            |
    +---------------------+--------------------------------------+
    

To attach a volume to an instance:

  1. Attach your volume to a server.

    $ openstack server add volume <INSTANCE_ID> <VOLUME_ID> --device <DEVICE_NAME>
    

    Note the ID of your volume.

  2. Show information for your volume.

    $ openstack volume show <VOLUME_ID>
    
    +---------------------------------------+-------------------------------------------------------------------------------------------+
    | Field                                 | Value                                                                                     |
    +---------------------------------------+-------------------------------------------------------------------------------------------+
    | attachments                           | [{u'server_id': u'<server_id>', u'attachment_id': u'<attachment_id>',u'host_name': None,  |
    |                                       | u'volume_id': u'<volume_id>', u'device': u'/dev/vdb', u'id': u'<volume_id>'}]             |
    | availability_zone                     | stage1                                                                                    |
    | bootable                              | false                                                                                     |
    | consistencygroup_id                   | None                                                                                      |
    | created_at                            | 2017-05-15T18:24:13.000000                                                                |
    | description                           | None                                                                                      |
    | encrypted                             | False                                                                                     |
    | id                                    | <volume_id>                                                                               |
    | migration_status                      | None                                                                                      |
    | multiattach                           | False                                                                                     |
    | name                                  | hg-test-vol                                                                               |
    | os-vol-host-attr:host                 | Host.AZ@volume-type#volume-type                                                           |
    | os-vol-mig-status-attr:migstat        | None                                                                                      |
    | os-vol-mig-status-attr:name_id        | None                                                                                      |
    | os-vol-tenant-attr:tenant_id          | <tenant_id>                                                                               |
    | os-volume-replication:driver_data     | None                                                                                      |
    | os-volume-replication:extended_status | None                                                                                      |
    | properties                            | attached_mode='rw', readonly='False'                                                      |
    | replication_status                    | disabled                                                                                  |
    | size                                  | 40                                                                                        |
    | snapshot_id                           | None                                                                                      |
    | source_volid                          | None                                                                                      |
    | status                                | in-use                                                                                    |
    | type                                  | ceph                                                                                      |
    | user_id                               | <user_id>                                                                                 |
    +---------------------------------------+-------------------------------------------------------------------------------------------+
    

To resize a volume:

  1. Detach the volume from your server.

    $ openstack server remove volume <INSTANCE_ID> <VOLUME_ID>
    

    The remove volume command does not return any output.

  2. List available volumes.

    $ openstack image list
    | ID           | Name                              | Status |
    |--------------|-----------------------------------|--------|
    | <iamge_id>   | my-new-volume                     | active |
    | <image_id>   | ubuntu_1204_server_cloudimg_amd64 | active |
    
    
  3. Resize the volume.

    $ cinder extend <VOLUME_ID> <SIZE>
    

    The extend command does not return any output.

To delete a volume:

  1. Detach the volume from your server.

    $ openstack server remove volume <INSTANCE_ID> <VOLUME_ID>
    
  2. Delete the volume using either the volume name or ID.

    $ openstack volume delete <VOLUME_ID>
    

    The delete command does not return any output.

  3. List the volumes again, and note that the status of your volume is deleting.

    $ openstack image list
    | ID           | Name                              | Status   |
    |--------------|-----------------------------------|----------|
    | <image_id>   | my-new-volume                     | deleting |
    | <image_id>   | ubuntu_1204_server_cloudimg_amd64 | active   |
    | <image_id>   | test-my-first-snapshot            | active   |
    

    When the volume is deleted, it does not display in the list of volumes.

    $ openstack image list
    | ID           | Name                                  | Status |
    |--------------|---------------------------------------|--------|
    | <image_id>   | ubuntu_1204_server_cloudimg_amd64     | active |
    | <image_id>   | test-my-first-snapshot                | active |
    | <image_id>   | Ubuntu-Server-16.04-CloudImage-raw    | active |
    

Transfering a Volume

You can transfer a volume from one owner to another by using the openstack volume transfer request* commands. 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.

Note
The procedure for volume transfer is intended for tenants (both the volume donor and recipient) within the same cloud.

You can transfer a volume to perform the following:

  • Create a custom bootable volume or a volume with a large data set and transfer it to a customer.

  • Complete bulk import of data to the cloud, the data ingress system creates a new Block Storage volume, copies data from the physical device, and transfers device ownership to the end user.

To create a volume transfer request:

  1. List the available volumes.

    $ openstack image list
    | ID           | Name                              | Status |
    |--------------|-----------------------------------|--------|
    | <image_id>   | my-new-volume                     | active |
    | <image_id>   | ubuntu_1204_server_cloudimg_amd64 | active |
    | <image_id>   | test-my-first-snapshot            | active |
    
  2. Request a volume transfer authorization code for a specific volume.

    $ openstack volume transfer request create <VOLUME_ID>
    

    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. For example:

    $ openstack volume transfer request create <TRANSFER_ID>
    

    The output shows the volume transfer ID in the id row and the authorization key.

  3. Specify a name for the transfer by using the --display-name <DISPLAY_NAME> parameter.

    |  Property  |  Value                       |
    |------------|------------------------------|
    | auth_key   |  <auth_key>                  |
    | created_at |  2013-10-14T15:20:10.121458  |
    | id         | <transfer_id>                |
    | name       |  None                        |
    | volume_id  | <volume_id>                  |
    

    Note
    While the auth_key property is visible in the output of openstack volume transfer request create <VOLUME_ID>, it will not be available in subsequent openstack volume transfer request show <TRANSFER_ID> commands.

  4. Send the volume transfer id and authorization key to the new owner (for example, by email).

  5. View pending transfers.

    $ openstack volume transfer request list
    | ID            | VolumeID       | Name |
    |---------------|----------------|------|
    | <transfer_id> | <volume_id>    | None |
    

    After the volume recipient, or new owner, accepts the transfer, the volume will not display in the transfer list.

To accept a volume transfer request:

  1. Obtain the transfer ID and authorization key from the original owner.

  2. Accept the request.

    $ openstack volume transfer request accept <TRANSFER_ID> <AUTH_KEY>
    | Property  | Value         |
    |-----------|---------------|
    | id        | <transfer_id> |
    | name      | None          |
    | volume_id | <volume_id>   |
    

    Note
    If you do not have a sufficient quota for the transfer, the transfer is refused.

To delete a volume transfer:

  1. List available volumes and their statuses. Ensure the volume transfer you are deleting is awaiting-transfer.

    $ openstack volume list
    | ID           | Display Name | Status            | Size | Attached to |
    |--------------|--------------|-------------------|------|-------------|
    | <volume_id>  | interop-vol  | available         |    3 |             |
    | <volume_id>  | block-test   | awaiting-transfer |    3 |             |
    
    
  2. Locate the matching transfer ID.

    $ openstack volume transfer volume request list
    | ID            | VolumeID      | Name |
    |---------------|---------------|------|
    | <transfer_id> | <volume_id>   | None |
    
  3. Delete the volume.

    $ openstack volume transfer request delete <TRANSFER_ID>
    
  4. Verify that transfer list is now empty and that the volume is again available for transfer.

    $ openstack volume transfer volume request list 
    | ID | Volume ID | Name |
    |----|-----------|------|