Attaching a Storage Volume to an Instance

When you attach a storage volume to an instance, the volume remains attached until the instance or storage attachment is deleted.

  1. Log in to the UI and go to the Self Service Portal.
    If you are performing this task in a 17.1.2 system see also Attaching a Storage Volume to an Instance on X5.
  2. In the Home tab, click an orchestration in the Services section.
    All the instances in the orchestration are displayed.
  3. In the Name column, click an instance for which you want to attach the storage volume.
  4. In the instance details page, click Attach in the Storage section.
  5. In the Attach Storage window, select a storage volume that you want to attach to the instance.
  6. Enter the index value for the storage volume. The index value must be between 1 and 10.
    The index number that you specify here determines the device name. The volume attached at index 1 is named /dev/vda or /dev/sda (depending on the use of VirtIO drivers by the instance), and the volume at index 2 is /dev/[sv]db and so on.
  7. Click Attach.

Attaching a Storage Volume to an Instance Using the CLI or API

Use the following command to attach a storage volume to an instance:

oracle-compute add storageattachment instance_name storage_volume_name index

The index value must be between 1 and 10.

For more information, see CLI Reference for Oracle Compute Cloud Service.

To attach a storage volume to an instance using the API, use the POST https://api.oc.example.com/storage/attachment method.

For more information, see REST API Reference for Oracle Compute Cloud Service.

Attaching a Storage Volume to an Instance on a 17.1.2 System

If you are attaching a storage volume to an instance on an 17.1.2 system, perform the following best practices:

  1. When you create a new instance, the customer must define the necessary storage attachments in the orchestration (attach during creation). This is preferable to attaching volumes after the instance is running, defined as a hot plug. see the example for Single Instance with Storage Attachment at Sample Orchestrations.
  2. If an instance has hot plugged storage attachments, then the customer should keep a copy of the instance definition using the command oracle-compute get instance <instance-name> -fjson. The customer can use this saved copy to look up the hot plugged storage attachments and reattach them in case they get detached, such as in the event of a power outage. If a power outage already happened, the hot plug information can't be retrieved using the command.