# Migrate a Linux VM from vSphere to KVM

In this guide, we will migrate a Linux VM from vSphere to KVM. For VMs with multiple disks, see the support article on [Migrate Secondary Linux VM Disk from vSphere to OpenStack](/managed-openstack/5.8/tutorials/tutorials-migrate-vm-vmware-pmo.md) for migrating the secondary disks, and follow the steps below for the boot disk.

### Requirements

* A vSphere VM with Linux installed
* The VM must only have one boot disk.

**Attention**

This article assumes that if the boot 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 boot disk by editing the settings of the VM and selecting the Virtual Disk. The boot disk will usually be the first disk listed, unless there is a bios.hddOrder value in the .vmx file for the VM.

<figure><img src="/files/aKdN2FLLRKFlbx3VKS3H" alt=""><figcaption></figcaption></figure>

Copy the flat VMDK from the ESX host to the Image Library, or a machine with the qemu-img command available.

<figure><img src="/files/bXu9HHAMIzkeYmjDeUkV" alt=""><figcaption></figcaption></figure>

After copying, convert the VMDK to a QCOW2 image.

{% tabs %}
{% tab title="Bash" %}

```bash
qemu-img convert -O qcow2 <input vmdk file> <ouput qcow2 file>
```

{% endtab %}
{% endtabs %}

For example:

{% tabs %}
{% tab title="Bash" %}

```bash
qemu-img convert -O qcow2 centos6-vm-migration-flat.vmdk centos6-vm-migration.qcow2
```

{% endtab %}
{% endtabs %}

### 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.

<figure><img src="/files/BYnKdt1VFf8aewLHOsXx" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/1BqHhOO3oN0Ekj5INNLi" alt=""><figcaption></figcaption></figure>

**OR**

Follow our support guide on \[auto$]\(/openstack/images-mange-images-cli#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.

For example:

{% tabs %}
{% tab title="OpenStack" %}

```bash
glance image-create --disk-format qcow2 \
--container-format bare \
--file centos6-vm-migration.qcow2 \
--visibility public \
--name centos6-vm-migration \
--property pf9_description="Linux VM migrated from vSphere" \
--property pf9_virtual_size=26422542336
```

{% endtab %}
{% endtabs %}

### Step 3 - Create an Instance

Create an instance as you normally would and your newly migrated Linux VM should now be running in a KVM environment.

<figure><img src="/files/Wj2tdsWlFS3YUOPAYcu6" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.platform9.com/managed-openstack/5.8/tutorials/tutorials-migrate-vm-vmware-kvm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
