Command-line
Once authenticated to Keystone - perform the following actions to attach a block storage volume to a virtual machine.
- Obtain the name or unique ID of the virtual machine you wish to attach the volume to
[wflintstone@login1(demo) ~]$ openstack server list
+--------------------------------------+----------------------------------------------------+--------+-----------------------------+
| ID | Name | Status | Networks |
+--------------------------------------+----------------------------------------------------+--------+-----------------------------+
| 30196e55-abce-4a69-9b32-80ed1b0a2953 | stack-group-rgkn2vuwwmkx-hilz2t2bvmio-sqd77nuxwl2u | ACTIVE | hpc1=10.75.0.6 |
| 4173c933-bcf5-42dc-b611-c566c928c883 | stack-group-rgkn2vuwwmkx-xptrxb7wkrbc-e3n724dnwkoy | ACTIVE | hpc1=10.75.0.5 |
| 2434a5ce-87f3-4571-b0ee-ea74fd4b8757 | stack-group-rgkn2vuwwmkx-ahzhik3vwuq7-qta43y6eqz3m | ACTIVE | hpc1=10.75.0.4 |
| b46012ac-8cb4-41f8-9cb9-a57e13a20550 | login1 | ACTIVE | hpc1=10.75.0.3, 10.77.0.134 |
+--------------------------------------+----------------------------------------------------+--------+-----------------------------+
$ VM="b46012ac-8cb4-41f8-9cb9-a57e13a20550"
- Obtain the name or unique ID of the block storage volume you wish to attach to the instance
[wflintstone@login1(demo) ~]$ openstack volume list
+--------------------------------------+--------------+-----------+------+-------------+
| ID | Display Name | Status | Size | Attached to |
+--------------------------------------+--------------+-----------+------+-------------+
| 835b9f57-8299-4bec-bf94-3256d445168b | refdata01 | available | 5 | |
+--------------------------------------+--------------+-----------+------+-------------+
Attach the volume
- Attach the volume to the instance and verify success:
[wflintstone@login1(demo) ~]$ openstack server add volume login1 refdata01
[wflintstone@login1(demo) ~]$ openstack volume list
+--------------------------------------+--------------+--------+------+---------------------------------+
| ID | Display Name | Status | Size | Attached to |
+--------------------------------------+--------------+--------+------+---------------------------------+
| 835b9f57-8299-4bec-bf94-3256d445168b | refdata01 | in-use | 5 | Attached to login1 on /dev/vdb |
+--------------------------------------+--------------+--------+------+---------------------------------+