Attaching a Restored Boot Volume to an Existing Instance

I did some research on attaching a restored boot volume to an existing instance but per this document, it might not be possible.

Here is the part I think it may not be possible.

You can use a boot volume backup to create an instance or you can attach it to another instance as a data volume.

This kind of tells me you can only create a new instance from the backup or attach it as a data volume.

Well, I’m not giving up my hope. How about cloning? I wonder if you can attach the cloned boot volume to an existing instance? I will find out.

How to Backup an Instance and Restore on Oracle Cloud Infrastructure

Backup

I would like to backup the boot volume of an instance to Object Storage and be able to restore the backed up image. Here are the steps.

I am going to ssh into the instance that I provisioned and create a file under my home directory.

So I have test.txt under my home directory. And then, I am going to backup the boot volume in Object Storage.

If you click Boot Volume link, it takes you to the link.

And if you click the link, you get to see the following options.

Now, click on Boot Volume Backups link. Now you can create a Boot Volume Backup as you can see in the image below.

Once you click Create Boot Volume Backup button, you can create a backup like the below. Click on Create Boot Volume Backup blue button to start the process

Once backup is complete, you should see it’s available now.

Just to be able to check if the boot volume has been restored, I am adding another line in test.txt. When I restore the volume, the second line should be gone.

I’m going to run the following commands after the backup. I should be able to run those commands again to update the OS after restoring the boot volume.

sudo apt update && sudo apt upgrade

Restoration

If you navigate to Menu-> Storage -> Block Storage -> Boot Volume Backups, you should see the list of boot volume backup. Now click on the target backup.

Click on the target backup and then click Restore Boot Volume button.

Now if you navigate to Menu -> Storage -> Block Storage -> Boot Volumes, you can see the one you just restored.

Once the boot volume is restored, attach it to the instance you already have. But first, you have to stop the instance and detach the boot volume.

If you go to the boot volume section of the instance details, you can detach the boot volume.

Well, I am not seeing the action item to attach restored boot volume in the menu. So I am restoring to OCI CLI to see if it works.

The following command may just work for me.

oci compute boot-volume-attachment attach --boot-volume-id [text] --instance-id [text]

It looks easy enough. Well, but it didn’t work.

ServiceError:
{
    "code": "Conflict",
    "message": "Boot volume ocid1.bootvolume.oc1.iad.abuwcljro5zeuegg7i2ms7xoaxgeft5mpef3ucykogfehtjhjde3zy676ddq cannot be attached to instance ocid1.instance.oc1.iad.anuwcljroksebviczqhtrjxzsu2d7angpz3bnpnl5z5gko27spvqlacxvicq. It can only be attached to its parent instance.",
    "opc-request-id": "98ECF81CD426418EB99DBB929733865A/38C80819B5A2267CEF1E0F89086F26D6/164678769EA39E4C60B724840D7F9F87",
    "status": 409
}

I googled it but could not figure out why. I will look into the issue when I have some time. Now my only option is to create a new instance out of the restored boot volume.

If you navigate to the restored boot volume, you can create a new instance.

Now that I was able to create an instance out of the restored boot volume, I was able to get the text.txt file I created in my home directory. And the second line I created after backing up was not there.

In a sense, this experiment was successful but I still need to figure out why I was not able to attach the restored boot volume to the existing instance.

Free Oracle Cloud Infrastructure Certification

Oracle is offering free Oracle Cloud Infrastructure certification taking. I got notified about it a few weeks ago and studied for it to get my certification for Oracle Cloud Infrastructure Foundation.

If you head on over to https://education.oracle.com/oracle-oci-certification, you can still access the study materials for free and take exams for free until 12/31/2021.