|
| 1 | +--- |
| 2 | +layout: "oci" |
| 3 | +page_title: "Provider: Oracle Cloud Infrastructure" |
| 4 | +sidebar_current: "docs-oci-guide-boot_volume_troubleshooting" |
| 5 | +description: |- |
| 6 | + The Oracle Cloud Infrastructure provider. Boot Volume reuse and troubleshooting |
| 7 | +--- |
| 8 | + |
| 9 | + |
| 10 | +## OCI Terraform Provider Boot volume reuse and troubleshooting |
| 11 | +This guide details the following scenarios:<br/> |
| 12 | +1. Preserving boot volume when performing instance scaling<br/> |
| 13 | +2. Boot volume troubleshooting and repair |
| 14 | + |
| 15 | +To read more about boot volumes, see [Boot Volumes](https://docs.cloud.oracle.com/iaas/Content/Block/Concepts/bootvolumes.htm) |
| 16 | + |
| 17 | + |
| 18 | +### Preserve boot volume with instance scaling |
| 19 | + |
| 20 | +You may want to upscale / downscale instances (change instance shape) while using the same boot volume. When you terminate |
| 21 | +your instance, you can keep the associated boot volume and use it to launch a new instance using a different instance type |
| 22 | +or shape. |
| 23 | + |
| 24 | +To achieve this, you need to detach the boot volume from the running instance. This can be performed by either |
| 25 | +terminating the instance while preserving the boot volume or by stopping the instance and detaching the boot volume, |
| 26 | + |
| 27 | +All terraform resources of type `oci_core_instance` have the parameter `preserve_boot_volume` set as true by default. |
| 28 | +This parameter ensures that upon termination of the instance, the attached boot volume is not terminated. |
| 29 | + |
| 30 | +``` |
| 31 | +resource "oci_core_instance" "TFInstance" { |
| 32 | + ... |
| 33 | + state = "STOPPED" // set this state to stop the instance |
| 34 | + preserve_boot_volume = true |
| 35 | +} |
| 36 | +
|
| 37 | +output "bootVolumeFromInstance" { |
| 38 | + value = ["${oci_core_instance.TFInstance.boot_volume_id}"] |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +Once the boot volume is detached, the OCID of the boot volume can be referred as the source of the new instance, as |
| 43 | +illustrated below |
| 44 | + |
| 45 | +``` |
| 46 | +resource "oci_core_instance" "TFScaleInstance" { |
| 47 | + ... |
| 48 | + source_details { |
| 49 | + source_type = "bootVolume" |
| 50 | + |
| 51 | + // reference the original boot volume id here |
| 52 | + source_id = "ocid1.bootvolume.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
| 53 | + } |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | + |
| 58 | +<br/> |
| 59 | +### OCI Terraform Provider boot volume troubleshooting and repair |
| 60 | + |
| 61 | +If you think a boot volume issue is causing a compute instance problem, you can stop the instance and detach the boot volume. |
| 62 | +Then you can attach it to another instance as a data volume to troubleshoot it. After resolving the issue, you can then |
| 63 | +reattach it to the original instance or use it to launch a new instance. |
| 64 | + |
| 65 | +Once the boot volume has been detached, the OCID of the boot volume can be referred as the block volume parameter for |
| 66 | +another instance. |
| 67 | + |
| 68 | +``` |
| 69 | +resource "oci_core_volume_attachment" "TFBlockAttach" { |
| 70 | + ... |
| 71 | + attachment_type = "iscsi" |
| 72 | + compartment_id = "ocid1.compartment.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
| 73 | + |
| 74 | + // new instance |
| 75 | + instance_id = "ocid1.instance.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
| 76 | + |
| 77 | + // attach the boot volume as a block volume |
| 78 | + volume_id = "ocid1.bootvolume.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +Once you have resolved the issue, detach this volume from the second instance and attach it as a boot volume to the |
| 83 | +original instance. |
| 84 | + |
| 85 | +``` |
| 86 | +resource "oci_core_instance" "TFScaleInstance" { |
| 87 | + ... |
| 88 | +
|
| 89 | + source_details { |
| 90 | + source_type = "bootVolume" |
| 91 | + |
| 92 | + // attach back as boot volume |
| 93 | + // reference the volume id here |
| 94 | + source_id = "ocid1.bootvolume.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
| 95 | + } |
| 96 | +} |
| 97 | +``` |
| 98 | + |
0 commit comments