Recovering an Oracle Cloud instance

in Cloud & Serverless


Use case: you have an Oracle Cloud instance but lost SSH access to it. To recover access, you need to know which pubkey you used on it, or which port SSH is listening on. Or, you don't want to terminate it before you make sure it doesn't contain important data.

Solution: you will have to clone a boot volume of that instance and attach it to another 'dummy' instance

Clone the boot volume

  1. Go to https://cloud.oracle.com/block-storage/boot-volumes
  2. Find the boot volume of the instance you need to recover. Click the three dots on it and Create Clone. Give the new clone a name that makes sense (so you can recognise it later when cleaning up).

Create an empty dummy instance

Attach the cloned volume to the dummy instance

  1. Open your dummy instance and under Resources on the left click Attached block volumesAttach block volume
  2. In the pop-up that appears:
    • Volume: choose your cloned volume
    • Attachment type: Paravirtualized
    • Access: Read/write

At this point, your dummy instance should see the newly attached volume without rebooting

Mount the volume on the dummy instance

SSH into your dummy instance and elevate to root (sudo su -)

  1. Run lsblk -o NAME,FSTYPE,LABEL,SIZE,MOUNTPOINT (alternatively, fdisk -l) to list the volumes attached to your instance. The cloned volume you just attached is likely to be listed last and it's partitions won't have a mountpoint.
  2. Create a directory to mount into mkdir /mnt/recovery
  3. mount -t auto -v /dev/sdb1 /mnt/recovery

The files from the attached volume are available at /mnt/recovery

Cleaning up

Oracle may charge you for the extra resources you just created. Clean up to avoid unnecessary costs

  1. Terminate the dummy instance
  2. Terminate the boot volume for the dummy instance
  3. Terminate the cloned volume

Additional resources:

#oracle-cloud-infrastructure