8.6. Attaching a Volume

This procedure details the steps involved in attaching a Block Storage volume to an existing Compute instance using the cinder and nova command line interfaces.

Procedure 8.4. Attaching a Volume using the Command Line Interface

  1. Use the keystonerc_admin file to authenticate with the Identity service.
    $ source ~/keystonerc_admin
  2. Use the cinder list command to find available volumes.
    $ cinder list
    +---------------------------+---------+------------+----+-----------+
    |              ID           | Status  |Display Name|Size|Volume Type|
    +---------------------------+---------+------------+----+-----------+
    |15a9f901-ba9d-45e1-8622-...|available|    NAME    | 1  |           |
    +---------------------------+---------+------------+----+-----------+
    Take note of the ID of the volume you wish to use. You will need it when attaching the volume to an instance.

    Note

    The Attached to column has been intentionally omitted from this example output.
  3. Use the nova list command to find running instances.
    $ nova list
    +-----------------------------+------+--------+----------------------+
    |              ID             | Name | Status |      Networks        |
    +-----------------------------+------+--------+----------------------+
    | 6842461c-973d-f91b-170a-... | NAME | ACTIVE | private=192.0.43.10  |
    +-----------------------------+------+--------+----------------------+
    Take note of the ID of the instance you wish to use. You will need it when attaching the volume.
  4. Use the nova volume-attach command to attach the volume to the instance. Replace INSTANCE_ID with the identifier of the instance and replace VOLUME_ID with the identifier of the volume.
    $ nova volume-attach INSTANCE_ID VOLUME_ID auto
    The auto parameter indicates that Compute must attempt to automatically assign a device identifier to the volume within the guest. Manual allocation of specific device identifiers within the guest is not supported on KVM hypervisors at this time.
You have successfully attached a Block Storage volume to an instance using the command line interface. The volume will appear as a physical hard disk drive to the guest operating system.