Migrate disks

Migrate to Virtual Machines lets you migrate unattached disks from an AWS source to Persistent Disk volumes on Google Cloud. This feature is useful when you want to migrate your unattached disks, that is, disks that are not connected to any virtual machine (VM) instance to Google Cloud.

For unattached disks, Migrate to Virtual Machines doesn't perform replication cycles because the disks are not active, as they are not connected to a VM. The data in the disk is copied in a one-time operation.

Before you begin

Before you begin the migration process, do the following:

Limitations

The following limitations apply:

  • You can only migrate disks from AWS sources.
  • You can only use REST APIs to migrate the disks.
  • Regional disks and hyperdisk disks are not supported.

Disk migration process

To migrate unattached disks to Google Cloud, use the following steps:

  1. In the Cloud Shell terminal, define a convenient shell alias for calling Google REST APIs:

    alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
    
  2. Create a disk migration job using the following REST command:

    gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/?disk_migration_job_id=DISK_MIGRATION_JOB -X POST --data '{
      "aws_source_disk_details":{"volume_id":"AWS_VOLUME_ID"},
      "target_details":{
        "target_disk":{
          "disk_id":"TARGET_DISK_ID",
          "zone":"TARGET_ZONE",
          "disk_type":"DISK_TYPE"
        },
        "target_project":"projects/HOST_PROJECT/locations/global/targetProjects/TARGET_PROJECT",
        "labels":{CUSTOM_LABELS},
        "encryption":{"kms_key":"KMS_KEY"}
      }
    }'
    

    Replace the following:

    • HOST_PROJECT: the name of the host project from which you want to migrate the disks.
    • LOCATION: the zone in which you want the disk migration process to run. For a list of supported zones, see Regions and Zones.
    • M2VM_SOURCE: the cloud source from which you want to migrate the disks. Note that you can only migrate disks from AWS sources in the Preview stage.
    • DISK_MIGRATION_JOB: the ID of the disk migration job. For information on naming convention for Compute Engine resources, see Naming conventions.
    • AWS_VOLUME_ID: the names of the disks that you want to migrate.
    • TARGET_DISK_ID: the ID of the target disk. For information on naming convention for Compute Engine resources, see Naming conventions.
    • TARGET_PROJECT: the ID of the target project to which you want to migrate the disks. If you've not already added a target project, do so using the instructions given in Add a target project.
    • TARGET_ZONE: zone of the target project. See Regions and Zones.
    • DISK_TYPE: the type of persistent disk that you want to migrate your disks to. Migrate to Virtual Machines supports the following disk types:
      • COMPUTE_ENGINE_DISK_TYPE_STANDARD: a Standard disk type.
      • COMPUTE_ENGINE_DISK_TYPE_SSD: a SSD hard disk type.
      • COMPUTE_ENGINE_DISK_TYPE_BALANCED: an alternative to SSD persistent disks that balance performance and cost.
      • COMPUTE_ENGINE_DISK_TYPE_HYPERDISK_BALANCED: hyperdisk balanced disk type.
    • (Optional) CUSTOM_LABELS: any labels you want to give the migrated disk. For example, "key1":"val1", "key2":"val2".
    • (Optional) KMS_KEY: the KMS key you want to use for the migrated disk. For more information, see Cloud Key Management Service overview.
  3. (Optional) Update the target details. The target project is the project that contains the migrated disk. You can configure the target details including project, zone, and disk type based on your preferences. You can modify the target details at any time. You can use the command given in the previous step to update the target details as well.

     gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/DISK_MIGRATION_JOB\?update_mask\=target_details  -X PATCH --data '{
     "target_details":{
       "target_disk":{
          "disk_id":"TARGET_DISK_ID",
          "zone":"TARGET_ZONE",
          "disk_type":"DISK_TYPE"
        },
       "target_project":"projects/HOST_PROJECT/locations/global/targetProjects/TARGET_PROJECT",
       "labels":{CUSTOM_LABELS},
       "encryption":{"kms_key":"KMS_KEY"}
      }
    }'
    
  4. Run the migration job using the following REST command:

    gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/DISK_MIGRATION_JOB:run -X POST
  5. Poll the job to check its status using the following REST command:

    gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/DISK_MIGRATION_JOB

Supported REST API operations for single disk migrations

Migrate to Virtual Machines supports the following REST API operations to migrate a single disk:

Create a disk migration job

gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/?disk_migration_job_id=DISK_MIGRATION_JOB -X POST --data '{
  "aws_source_disk_details":{"volume_id":"AWS_VOLUME_ID"},
  "target_details":{
    "target_disk":{
      "disk_id":"TARGET_DISK_ID",
      "zone":"TARGET_ZONE",
      "disk_type":"DISK_TYPE"
    },
    "target_project":"projects/HOST_PROJECT/locations/global/targetProjects/TARGET_PROJECT",
    "labels":{CUSTOM_LABELS},
    "encryption":{"kms_key":"KMS_KEY"}
  }
}'

Replace the following:

  • HOST_PROJECT: the name of the host project from which you want to migrate the disks.
  • LOCATION: the zone in which you want the disk migration process to run. For a list of supported zones, see Regions and Zones.
  • M2VM_SOURCE: the cloud source from which you want to migrate the disks. Note that you can only migrate disks from AWS sources in the Preview stage.
  • DISK_MIGRATION_JOB: the ID of the disk migration job. For information on naming convention for Compute Engine resources, see Naming conventions.
  • AWS_VOLUME_ID: the names of the disks that you want to migrate.
  • TARGET_DISK_ID: the ID of the target disk. For information on naming convention for Compute Engine resources, see Naming conventions.
  • TARGET_PROJECT: the ID of the target project to which you want to migrate the disks. If you've not already added a target project, do so using the instructions given in Add a target project.
  • TARGET_ZONE: zone of the target project. See Regions and Zones.
  • DISK_TYPE: the type of persistent disk that you want to migrate your disks to. Migrate to Virtual Machines supports the following disk types:
    • COMPUTE_ENGINE_DISK_TYPE_STANDARD: a Standard disk type.
    • COMPUTE_ENGINE_DISK_TYPE_SSD: a SSD hard disk type.
    • COMPUTE_ENGINE_DISK_TYPE_BALANCED: an alternative to SSD persistent disks that balance performance and cost.
    • COMPUTE_ENGINE_DISK_TYPE_HYPERDISK_BALANCED: hyperdisk balanced disk type.
  • (Optional) CUSTOM_LABELS: any labels you want to give the migrated disk. For example, "key1":"val1", "key2":"val2".
  • (Optional) KMS_KEY: the KMS key you want to use for the migrated disk. For more information, see Cloud Key Management Service overview.

Update a disk migration job

gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/DISK_MIGRATION_JOB\?update_mask\=target_details  -X PATCH --data '{
  "target_details":{
    "target_disk":{
      "disk_id":"TARGET_DISK_ID",
      "zone":"TARGET_ZONE",
      "disk_type":"DISK_TYPE"
    },
    "target_project":"projects/HOST_PROJECT/locations/global/targetProjects/TARGET_PROJECT",
    "labels":{CUSTOM_LABELS},
    "encryption":{"kms_key":"KMS_KEY"}
  }
}'

Get a disk migration job

gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/DISK_MIGRATION_JOB

List disk migration jobs

gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs

Run a disk migration job

gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/DISK_MIGRATION_JOB:run -X POST

Cancel a disk migration job

gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/DISK_MIGRATION_JOB:cancel -X POST

Delete a disk migration job

gcurl https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/DISK_MIGRATION_JOB -X DELETE

REST API scripts for batch disk migrations

Use the following the REST API scripts to perform batch disk migration tasks.

Create a batch disk migration job

token=`gcloud auth print-access-token`
for PAIR in `echo "SRC_TARGET_PAIRS" |tr -d ' '|tr ',' ' '`;
do
  vol=${PAIR%:*}
  disk=${PAIR#*:}
  curl -H "Authorization: Bearer $token" -H "Content-Type: application/json" https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs\?disk_migration_job_id\=dmj-${vol}  -X POST -d '{
    "aws_source_disk_details":{"volume_id":"'${vol}'"},
    "target_details":{
      "target_disk":{
        "disk_id":"'${disk}'",
        "zone":"TARGET_ZONE",
        "disk_type":"DISK_TYPE"
      },
      "target_project":"projects/HOST_PROJECT/locations/global/targetProjects/TARGET_PROJECT",
      "labels":{CUSTOM_LABELS},
      "encryption":{"kms_key":"KMS_KEY"}
    }
  }'
done

Replace the following:

  • SRC_TARGET_PAIRS: a comma-separated list of SOURCE:TARGET pairs. For example, vol1:disk1, vol2:disk2.
  • HOST_PROJECT: the name of the host project from which you want to migrate the disks.
  • LOCATION: the zone in which you want the disk migration process to run. For a list of supported zones, see Regions and Zones.
  • M2VM_SOURCE: the cloud source from which you want to migrate the disks. Note that you can only migrate disks from AWS sources in the Preview stage.
  • DISK_MIGRATION_JOB: the ID of the disk migration job. For information on naming convention for Compute Engine resources, see Naming conventions.
  • AWS_VOLUME_ID: the names of the disks that you want to migrate.
  • TARGET_DISK_ID: the ID of the target disk. For information on naming convention for Compute Engine resources, see Naming conventions.
  • TARGET_PROJECT: the ID of the target project to which you want to migrate the disks. If you've not already added a target project, do so using the instructions given in Add a target project.
  • TARGET_ZONE: zone of the target project. See Regions and Zones.
  • DISK_TYPE: the type of persistent disk that you want to migrate your disks to. Migrate to Virtual Machines supports the following disk types:
    • COMPUTE_ENGINE_DISK_TYPE_STANDARD: a Standard disk type.
    • COMPUTE_ENGINE_DISK_TYPE_SSD: a SSD hard disk type.
    • COMPUTE_ENGINE_DISK_TYPE_BALANCED: an alternative to SSD persistent disks that balance performance and cost.
    • COMPUTE_ENGINE_DISK_TYPE_HYPERDISK_BALANCED: hyperdisk balanced disk type.
  • CUSTOM_LABELS: any labels you want to give the migrated disk. For example, "key1":"val1", "key2":"val2".
  • KMS_KEY: the KMS key you want to use for the migrated disk. For more information, see Cloud Key Management Service overview.

Update a batch disk migration job

token=`gcloud auth print-access-token`
for PAIR in `echo "SRC_TARGET_PAIRS" |tr -d ' '|tr ',' ' '`;
do
  vol=${PAIR%:*}
  disk=${PAIR#*:}
  curl -H "Authorization: Bearer $token" -H "Content-Type: application/json" https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/dmj-${vol}\?update_mask\=target_details -X PATCH -d '{
    "target_details":{
      "target_disk":{
        "disk_id":"'${disk}'",
        "zone":"TARGET_ZONE",
        "disk_type":"DISK_TYPE"
      },
      "target_project":"projects/HOST_PROJECT/locations/global/targetProjects/TARGET_PROJECT",
      "labels":{CUSTOM_LABELS},
      "encryption":{"kms_key":"KMS_KEY"}
    }
  }'
done

Get a batch disk migration job

token=`gcloud auth print-access-token`
for PAIR in `echo "SRC_TARGET_PAIRS" |tr -d ' '|tr ',' ' '`;
do
  vol=${PAIR%:*}
  disk=${PAIR#*:}
  curl -H "Authorization: Bearer $token" -H "Content-Type: application/json" https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/dmj-${vol};
done

List batch disk migration jobs

token=`gcloud auth print-access-token`
  curl -H "Authorization: Bearer $token" -H "Content-Type: application/json" https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs

Run a batch disk migration job

token=`gcloud auth print-access-token`
for PAIR in `echo "SRC_TARGET_PAIRS" |tr -d ' '|tr ',' ' '`;
do
  vol=${PAIR%:*}
  disk=${PAIR#*:}
  curl -H "Authorization: Bearer $token" -H "Content-Type: application/json" https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/dmj-${vol}:run -X POST;
done

Cancel a batch disk migration job

token=`gcloud auth print-access-token`
for PAIR in `echo "SRC_TARGET_PAIRS" |tr -d ' '|tr ',' ' '`;
do
  vol=${PAIR%:*}
  disk=${PAIR#*:}
  curl -H "Authorization: Bearer $token" -H "Content-Type: application/json" https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/dmj-${vol}:cancel -X POST;
done

Delete a batch disk migration job

token=`gcloud auth print-access-token`
for PAIR in `echo "SRC_TARGET_PAIRS" |tr -d ' '|tr ',' ' '`;
do
  vol=${PAIR%:*}
  disk=${PAIR#*:}
  curl -H "Authorization: Bearer $token" -H "Content-Type: application/json" https://vmmigration.googleapis.com/v1alpha1/projects/HOST_PROJECT/locations/LOCATION/sources/M2VM_SOURCE/diskMigrationJobs/dmj-${vol} -X DELETE;
done