Volume management

The Openstack volumes are provided by Cinder service. To access the commands it is necessary to install python-cinderclient that provides the cinder utility. Openstack volumes are the equivalent to the Amazon functionality Elastic Block Storage. They provide an elastic, sizeable on demand, reliable, efficient and persistent storage. At CC-IN2P3 this storage is provided by a Ceph cluster.

List the instantiated volumes

% openstack volume list --long
+---------+-----------+--------------+------+--------------------+----------+--------------------------------------+
|   ID    |   Status  | Display Name | Size | Volume Type        | Bootable |             Attached to              |
+---------+-----------+--------------+------+--------------------+----------+--------------------------------------+
|  [...]  | available | testvol1     |  1   |     rad.regular    |          |                                      |
|  [...]  | detaching | testvol2     |  1   |     rad.regular    |          | c16d3ecb-f504-4cbc-8fa0-89facd5eb3f5 |
|  [...]  | available | vol4         |  1   |     ha.regular     |          |                                      |
|  [...]  | available | vol5         |  1   |     rad.regular    |          |                                      |
+---------+-----------+--------------+------+--------------------+----------+--------------------------------------+

Old command:

cinder list

List the volume types

Volume types allow you to choose the storage type you want to use (fast, capacitive ...). To list the availabe volume types in the project:

% openstack volume type list --long
+--------------------------------------+------------+-----------+--------------+---------------------------------------+
| ID                                   | Name       | Is Public | Description  | Properties                            |
+--------------------------------------+------------+-----------+--------------+---------------------------------------+
| a171dae9-73fb-4223-9b59-d59be044aef5 | ha.regular | True      | Ceph backend | volume_backend_name='volumes-service' |
+--------------------------------------+------------+-----------+--------------+---------------------------------------+

The volume type names are standardized and consist of the following: type.backend

where:

The type is set to {ha|rad|...}. It expresses the VM typical use case. Typically:

ha for "high availability" instances providing production services.
rad for R & D
...

The backend is set to {regular|fast|slow|...}. It indicates what type of storage is used for this volume type:

regular for commum / normal storage
fast for SSD storage for example
....

There is SSD storage but its use is strictly controlled. If you need this type of storage, let us know.

Create a new volume

% openstack volume create --size 5 --type ha.regular monvolume1
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|      created_at     |      2013-04-19T11:03:50.606663      |
| display_description |                 None                 |
|     display_name    |              monvolume1              |
|          id         | cb252a17-f581-4d70-8049-be358a5fc8bb |
|       metadata      |                  {}                  |
|         size        |                  5                   |
|     snapshot_id     |                 None                 |
|        status       |               creating               |
|     volume_type     |              ha.regular              |
+---------------------+--------------------------------------+

Attach a free volume to an instance

To attach a volume to an instance, we simply use the command:

% openstack server add volume <id/server_name> <id/volume_name>

The attached volume will automatically be seen by the system as a partition of type /vdb or /vfc. Example:

% openstack server add volume myserver myvolume

Once the volume is attached, the corresponding block device may be seen in the nova instance:

% grep -v vda /proc/partitions
major minor  #blocks  name

 252       16    1048576 vdb

Or

% lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda             252:0    0   10G  0 disk
├vda1          252:1    0  200M  0 part /boot
└vda2          252:2    0  7.8G  0 part
 ├rootvg-root 253:0    0 1000M  0 lvm  /
 ├rootvg-usr  253:1    0  3.4G  0 lvm  /usr
 ├rootvg-tmp  253:2    0  500M  0 lvm  /tmp
 └rootvg-var  253:3    0  2.5G  0 lvm  /var
vdb             252:16   0   5G  0 disk

For example, the space may be mounted with the following:

% mkfs.xfs /dev/vdb
% mkdir /data
% cat >> /etc/fstab <<EOF
/dev/vdb /data xfs nosuid,nodev 1 2
EOF
% mount /data

A more sophisticated alternative:

% pvcreate /dev/vdb
% vgcreate cindervolume /dev/vdb
% lvcreate -L5G -n part1 cindervolume
% mkfs.xfs /dev/cindervolume/part1
# proceeding as the previous case

Detach a volume

Detaching a volume does not delete the data. This is the Unix equivalent of detaching a LUN from a host. A volume can therefore be attached/detached as much as desired preserving data.

% openstack server remove volume myserver myvolume

Delete a volume

Warning

volume deletion will result in the stored data permanent removal.

% openstack volume delete 38ed8ee5-bcb6-4bea-91d4-5c25d8c21fdb

Volume Snapshot

Volume snapshot generates a Copy-On-Write of the volume, allowing to establish recovery points in time. Snapshots may be generated only from a detached and available volume.

% openstack volume snapshot create --volume monvolume1 monsnapshot
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|      created_at     |      2013-04-19T11:35:52.269821      |
| display_description |                 None                 |
|     display_name    |              monsnapshot             |
|          id         | bab83cd0-9b50-4440-abdc-3518edaa8f8c |
|         size        |                  5                   |
|        status       |               creating               |
|      volume_id      | 2cbbf9d7-248c-4489-8e37-5dbb0f351199 |
+---------------------+--------------------------------------+

The - -force option allows to snapshot a volume attached to an instance. In addition, snapshoting an instance that uses a lot its disk can be very time consuming.

List existing snapshots

% openstack volume snapshot list
+--------------------------------------+---------------+-------------+-----------+------+
| ID                                   | Name          | Description | Status    | Size |
+--------------------------------------+---------------+-------------+-----------+------+
| bab83cd0-9b50-4440-abdc-3518edaa8f8c | monsnapshot   | None        | available |   5  |
+--------------------------------------+---------------+-------------+-----------+------+

To verify the snapshot state:

% openstack volume snapshot show monsnapshot
+--------------------------------------------+--------------------------------------+
| Field                                      | Value                                |
+--------------------------------------------+--------------------------------------+
| created_at                                 | 2013-04-19T11:35:52.269821           |
| description                                | None                                 |
| id                                         | bab83cd0-9b50-4440-abdc-3518edaa8f8c |
| name                                       | monsnapshot                          |
| os-extended-snapshot-attributes:progress   | 100%                                 |
| os-extended-snapshot-attributes:project_id | 0223bc1968bc4e46932c5d87012aaf14     |
| properties                                 |                                      |
| size                                       | 5                                    |
| status                                     | available                            |
| updated_at                                 | 2013-04-19T11:35:52.269821           |
| volume_id                                  | cb252a17-f581-4d70-8049-be358a5fc8bb |
+--------------------------------------------+--------------------------------------+

Delete a snapshot

% openstack volume snapshot delete bab83cd0-9b50-4440-abdc-3518edaa8f8c

Attach a previously generated snapshot without destroying the current volume

This requires creating a new volume from a snapshot and then attaching the volume:

% openstack volume create --size 10 --snapshot monsnapshot --type rad.regular testsnap
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|      created_at     |      2013-04-19T11:40:14.917488      |
| display_description |                 None                 |
|     display_name    |               testsnap               |
|          id         | 16983673-fb34-4f7e-9eba-54cb5e59a13a |
|       metadata      |                  {}                  |
|         size        |                  10                  |
|     snapshot_id     | bab83cd0-9b50-4440-abdc-3518edaa8f8c |
|        status       |               creating               |
|     volume_type     |              rad.regular             |
+---------------------+--------------------------------------+
% openstack server add volume monserveur testsnap