Migrate a secondary Linux VM disk from vSphere to OpenStack
In this article, we will migrate a secondary Linux VM disk from vSphere to an OpenStack Cinder volume.
- A vSphere VM with Linux installed
- A secondary disk on the Linux VM
- A host with the Block Storage role
Note: This article assumes that if the secondary disk uses LVM, the LVM volumes do not span other disks
Step 1 – Convert VMDK to QCOW2
After powering off the VM, note the path of the secondary disk by selecting it in the VM settings. Secondary disks are usually listed after the first disk, unless there is a bios.hddOrder value in the .vmx file for the VM.
Copy the flat VMDK from the ESX host to the Image Library, or a machine with the qemu-img command available.
After copying, convert the VMDK to a QCOW2 image.[bash]qemu-img convert -O qcow2 <Input VMDK file> <Ouput QCOW2 file>[/bash]
For example:[bash]qemu-img convert -O qcow2 ubuntu14-vm-migration-flat.vmdk ubuntu14-vm-migration-secondary.qcow2[/bash]
Step 2 – Upload the Image to the Image Library Host
You can simply copy the converted qcow2 image to the Image library host’s image directory.
Follow our support guide on Managing Images with the OpenStack Glance Client if you are not familiar with the OpenStack Glance Client.
Then, use the glance command to upload the image.
glance image-create --disk-format qcow2 \
--container-format bare \
--file ubuntu14-vm-migration-secondary.qcow2 \
--visibility public \
--name ubuntu14-vm-migration-secondary \
--property pf9_description="Linux VM secondary disk migrated from vSphere" \
Step 3 – Create a Cinder Volume
The secondary disk image should now be present in the UI.
Create a volume from this image by clicking “Create New Volume” from the Volume and Snapshots view.
Select “Image” in the dropdown menu. Then, select the image for the secondary VM disk.
Click next, and complete the form to the finish creating the volume.
The volume should soon be in the available state.
Step 3 – Attach the migrated volume
From the Instances view, select the “Manage Volumes” action to attach the volume to a VM.
Ensure the volume is attached and click “Update Volumes”.
Step 3 – Verify the attached volume
When accessing the VM through the console or SSH, run the lsblk command to verify that the volume was attached.
Enjoy your newly migrated volume!