OCI Block Volume - Export Steps

This document is intended as guide for the steps OCI customers can take to extract OCI Block Volume data and move it to another cloud provider or to their on-prem facility. Similar steps can be used when migrating OCI Block Volume data across tenancies with restricted security access.

Option 1: Extract and Transfer Block Volume Data

If your block volume is not a boot volume, then the block volume data can be extracted manually and then converted to the proper format required by another Cloud Provider or for on-prem usage.

Step 1: Attach the Block Volume to an OCI Compute Instance

Prerequisite: A Linux-based compute instance must be available for attaching the block volume to.

  1. On the Block Volumes list page, select the block volume that you want to attach to an instance. If you need help finding the list page or the volumes, see Listing Volumes.
  2. On the details page, select Attached Instances.
  3. Select Attach to Instance.
  4. On the Attach to instance panel, enter the following information.
    • Attachment type: Select ISCI.
    • Instance: Select the instance that you want to attach the block volume to.
  5. Select Attach.
  6. Connect to the Linux instance by running each command in sequence, in the Console:
    Note

    All command arguments are essential. Success returns no response.
    sudo iscsiadm -m node -o new -T <volume-IQN> -p <iSCSI-IP-address>:<iSCSI-port>
    sudo iscsiadm -m node -T <volume-IQN> -o update -n node.startup -v automatic
    sudo iscsiadm -m node -T <volume-IQN> -p <iSCSI-IP-address>:<iSCSI-port> -l

    For more information on connecting to a volume on a Linux instance, see Connecting to a Volume on a Linux Instance.

  7. Verify the block device appears (typically as /dev/sdb or similar) by use of the Linux lsbk (list block devices) command:
    lsblk

Step 2: Create a Raw Disk Image

  1. Decide where to store the block volume image.
    • If the image file is small enough (for example, less than 100 GB), you can store it locally in /mnt/ or another large partition on the boot volume.
    • If the image file is large, you might need to attach an additional block volume to store it.
  2. Run the dd command to capture the entire block volume into a raw disk image:
    sudo dd if=/dev/sdb of=/mnt/volume.img bs=1M status=progress
    where:
    • /dev/sdb is the attached block volume.
    • /mnt/volume.img is the location to store the Block Volume image.
    • bs=1M indicates large blocks to improve read/write efficiency.
    • status=progress shows progress.

Step 3: Convert the Image to Another Format

Prerequisites: To get the functionality in this step, you might need to install qemu-img or qemu-tools on your distribution.

Convert the raw image to the required format based on the target cloud or on-prem destination:

  • qemu-img convert -f raw -O vmdk /mnt/volume.img /mnt/volume.vmdk
  • qemu-img convert -f raw -O vhdx /mnt/volume.img /mnt/volume.vhd
  • qemu-img convert -f raw -O qcow2 /mnt/volume.img /mnt/volume.qcow2

Step 4: Upload the Block Volume Image to OCI Object Storage

Move the image from the instance to a bucket using the following command:

oci os object put -bn my-bucket --file /mnt/<filename>

Example for an unconverted image:

oci os object put -bn my-bucket --file /mnt/volume.img

Example for an image converted to VMDK format:

oci os object put -bn my-bucket --file /mnt/volume.vmdk

Step 5: Transfer to Another Cloud Provider

    1. Download the block volume image from OCI Object Storage to your workstation:
      oci os object get -bn my-bucket --name volume.vmdk --file volume.vmdk
    2. Upload the block volume image from your workstation to AWS S3:
      aws s3 cp volume.vmdk s3://my-aws-bucket/
    3. Import an EBS volume:
      aws ec2 import-snapshot --disk-container Format=VMDK,UserBucket={S3Bucket=my-aws-bucket,S3Key=volume.vmdk}
    1. Download the block volume image from OCI Object Storage to your workstation:
      oci os object get -bn my-bucket --name volume.vmdk --file volume.vmdk
    2. Upload the block volume image from your workstation to Google Cloud Storage:
      gsutil cp volume.vmdk gs://my-gcp-bucket/
    3. Import the disk image:
      gcloud compute images import volume-image --source-file=gs://my-gcp-bucket/volume.vmdk --os=ubuntu-20-04
  • Prerequisite: The image must be converted to VHD format. See Step 3: Convert the Image to Another Format.
    1. Upload the block volume image from your workstation to Azure Blob Storage:
      az storage blob upload --account-name myaccount --container-name mycontainer --file volume.vhd --name volume.vhd
    2. In Azure, create a Managed Disk from the uploaded VHD:
      az disk create --resource-group myResourceGroup --name myManagedDisk --source https://myaccount.blob.core.windows.net/mycontainer/volume.vhd --os-type Linux

Option 2: Create a Bootable Image for a Boot Volume and Export It

If your block volume is attached to a compute instance as a boot volume, you can create a custom image and export it.

  1. Create a custom image from the instance that uses the block volume as a boot volume.
  2. Export the custom image to a bucket in Object Storage.
  3. Download and transfer the image:
    • Use the OCI CLI to download the exported image to your workstation:
      oci os object get -bn my-bucket --name exported-image.qcow2 --file exported-image.qcow2
    • Upload the file from your workstation to your target cloud provider and import it in the native virtual disk format using commands at Step 5: Transfer to Another Cloud Provider.
      • Amazon Web Services (AWS): Upload to S3, then convert it into an EBS snapshot.
      • Google Cloud Provider (GCP): Upload to Cloud Storage and create a persistent disk.
      • Microsoft Azure: Convert to VHD format, upload to Azure Blob Storage, then create a managed disk.