Attaching volumes to an instance
Now that we have a usable volume, we can attach it to any instance. We'll do this using the openstack server volume add
command.
Getting ready
To attach a volume to an instance, you will need the following:
The
openstack
command-line clientAn
openrc
file with appropriate credentials for the environmentThe name or ID of the volume to attach
The name or ID of the instance to attach the volume to
For our example, these values are as follows:
Volume:
cookbook.volume
Instance:
cookbook.test
How to do it...
Carry out the following steps to attach a volume to an instance using the openstack
client:
First, let's list running instances to get the ID of our instance:
openstack server list -c Name -c ID -f table
An example showing our running instance called
cookbook.test
is shown here:Now list the available volumes to get the ID of our volume:
openstack volume list
This shows the information we need about our volume:
Using the instance and volume name or IDs, we'll attach the...