---
title: "Getting started with managing volumes in the OpenStack API"
description: "You can use the OpenStack API to generate various scripts to automate your actions on the Public Cloud.\\"
url: https://docs.us.ovhcloud.com/en/public-cloud/compute/starting-with-managing-volumes-openstack-api
lang: en
---
> For AI agents: the complete documentation index is available at https://docs.us.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.us.ovhcloud.com/en/llms-full.txt.

# Getting started with managing volumes in the OpenStack API

You can use the OpenStack API to generate various scripts to automate your actions on the Public Cloud.\
For example, you can create a new high-performance volume to attach to a Public Cloud instance.

 

## Requirements

- Preparing the environment to [use the OpenStack API](https://docs.us.ovhcloud.com/en/public-cloud/cross-functional/compute-prepare-openstack-api-environment.md) by installing _python-cinderclient_ and _python-novaclient_
- Setting the [OpenStack environment variables](https://docs.us.ovhcloud.com/en/public-cloud/cross-functional/compute-set-openstack-environment-variables.md)

 

## Instructions

### Cinder documentation

You can get a list of possible commands by reading the OpenStack client documentation:

```bash
openstack help
```

Here is the list of the main commands:

| Command                | Description                   |
| ---------------------- | ----------------------------- |
| volume create          | Create a new volume           |
| volume delete          | Delete a volume               |
| list volume            | List volumes                  |
| volume snapshot create | Create a snapshot of a volume |

You can also get information about a specific command by adding `help` to it:

```bash
openstack help volume snapshot create
usage: openstack volume snapshot create [-h] [-f {json,shell,table,value,yaml}] [-c COLUMN] [------noindent] [------prefix PREFIX] [------max-width <integer>] [------fit-width] [------print-empty] [------volume <volume>] [------description <description>] [------force] [------property <key=value]
                                        [--remote-source <key=value>]
                                        <snapshot-name>

Create new volume snapshot

positional arguments:
  <snapshot-name> Name of the new snapshot

optional arguments:
  -h, ------help show this help message and exit
  --volume <volume>     Volume to snapshot (name or ID) (default is <snapshot-name>)
  ------description <description>
                        Description of the snapshot
  ------force Create a snapshot attached to an instance. Default is False
```

**Note:**

You can also consult the OpenStack documentation available on the [OpenStack website](https://docs.openstack.org/python-openstackclient/latest/).

 

### Basic operations

#### Creating a high-performance volume

- List the volume types:

```bash
openstack volume type list
```

```
+--------------------------------------+------------+-----------+
| ID                                   | Name       | Is Public |
+--------------------------------------+------------+-----------+
| e9551830-6362-4bf8-92e5-391829456b03 | classic    | True      |
| 6fc8e512-3cac-4f39-b9a8-af098d710506 | high-speed | True      |
+--------------------------------------+------------+-----------+
```

- Create the 10GB high-speed volume named **volume1**:

```bash
openstack volume create --type high-speed --size 10 volume1
```

```

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| attachments         | []                                   |
| availability_zone   | nova                                 |
| bootable            | false                                |
| consistencygroup_id | None                                 |
| created_at          | 2021-05-18T14:16:28.658308           |
| description         | None                                 |
| encrypted           | False                                |
| id                  | f75d60b3-4179-4ca9-8bc7-8e5f7a1682f8 |
| multiattach         | False                                |
| name                | volume1                              |
| properties          |                                      |
| replication_status  | disabled                             |
| size                | 10                                   |
| snapshot_id         | None                                 |
| source_volid        | None                                 |
| status              | creating                             |
| type                | high-speed                           |
| updated_at          | None                                 |
| user_id             | ...                                  |
+---------------------+--------------------------------------+
```

You can install an image on a volume using the `--image` argument:

In this command, **be66762f-b849-43e1-b57c-005d9fe28088** is the Debian 10 image ID.

```bash
openstack volume create --type high-speed --image be66762f-b849-43e1-b57c-005d9fe28088 --size 20 volume_debian
```

```
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| attachments         | []                                   |
| availability_zone   | nova                                 |
| bootable            | false                                |
| consistencygroup_id | None                                 |
| created_at          | 2021-05-18T14:26:38.887508           |
| description         | None                                 |
| encrypted           | False                                |
| id                  | 442d9dff-7df5-41b2-95e9-fa8ac5f4784a |
| multiattach         | False                                |
| name                | volume_debian                        |
| properties          |                                      |
| replication_status  | disabled                             |
| size                | 20                                   |
| snapshot_id         | None                                 |
| source_volid        | None                                 |
| status              | creating                             |
| type                | high-speed                           |
| updated_at          | None                                 |
| user_id             | ...                                  |
+---------------------+--------------------------------------+
```

 

#### Attaching a volume to an instance

- List the additional volumes:

```bash
openstack volume list
```

```
+--------------------------------------+---------------+-----------+------+-------------+
| ID                                   | Name          | Status    | Size | Attached to |
+--------------------------------------+---------------+-----------+------+-------------+
| 442d9dff-7df5-41b2-95e9-fa8ac5f4784a | volume_debian | available |   20 |             |
| f75d60b3-4179-4ca9-8bc7-8e5f7a1682f8 | volume1       | available |   10 |             |
+--------------------------------------+---------------+-----------+------+-------------+
```

**Note:**

The majority of subsequent commands will require the volume ID rather than the name.

- Mount the volume on an instance with the OpenStack client:

```bash
openstack server add volume 46aec29f-fe50-4562-b3f9-2e6665a7270d f75d60b3-4179-4ca9-8bc7-8e5f7a166 82f8
```

- Check that the volume has been properly attached to the instance with the OpenStack client:

```bash
openstack volume list
```

```
+--------------------------------------+---------------+-----------+------+-----------------------------------------+
| ID                                   | Name          | Status    | Size | Attached to                             |
+--------------------------------------+---------------+-----------+------+-----------------------------------------+
| 442d9dff-7df5-41b2-95e9-fa8ac5f4784a | volume_debian | available |   20 |                                         |
| f75d60b3-4179-4ca9-8bc7-8e5f7a1682f8 | volume1       | in-use    |   10 | Attached to cli-playground on /dev/sdb  |
+--------------------------------------+---------------+-----------+------+-----------------------------------------+
```

 

#### Deleting a volume

- Detach volume from instance:

```bash
openstack server remove volume 46aec29f-fe50-4562-b3f9-2e6665a7270d f75d60b3-4179-4ca9-8bc7-8e5f7a1682f8
```

- Delete volume:

```bash
openstack volume delete f75d60b3-4179-4ca9-8bc7-8e5f7a1682f8
```

 

## Go further

Browse all the [Compute guides](https://docs.us.ovhcloud.com/en/public-cloud/compute/landing-page-compute.md).

Browse the rest of the [OVHcloud US documentation](https://docs.us.ovhcloud.com/en/index.md) for guides on our other products and services.

Learn more about [Public Cloud Compute](https://us.ovhcloud.com/public-cloud/compute/) on the OVHcloud US website.
