Problem
There is no way to change the order of disks for a migrating VM.
Environment
- Compute Engine
Solution
The disks can be cloned and connected in the correct order to a new VM on Google Compute Engine.
- Stop the VM.
-
Clone the original boot disk:
gcloud compute disks create -project=$PROJECT --zone=$ZONE --source-disk=$DISK new-disk-name
-
Run the following to reassign the license to the boot disk and to add relevant tags (Example with windows2008-r2):
gcloud compute disks create --project=$PROJECT --zone=$ZONE --source-disk=<disk created on step #2> --licenses=projects/windows-cloud/global/licenses/windows-server-2008-r2-dc --guest-os-features=VIRTIO_SCSI_MULTIQUEUE,MULTI_IP_SUBNET,WINDOWS new-disk-name
- Detach the current boot disk and attach it to the Additional disks.
- Remove the original boot disk from the Additional disks.
- Attach the created disk from step above on the Boot Disk.
- Save the changes.
- After confirming the VM boot as well, you can delete the original boot disk.
Cause
If the boot partition is not on the first disk (the lowest index on the Bus) at the source, system boot for a test clone or cutover VM may fail. This could be identified by checking if the operating system is installed on the disk marked as the boot disk on the Google Compute Engine image.