How to Migrate Linux VM From VMware to KVM

Are you ready to take your Linux virtual machine (VM) to the next level by migrating it from VMware to KVM? It seems be a challenging task. In this article, we will guide you through the process of migration.

By @Zelia Last Updated December 14, 2023

KVM vs VMware

Both KVM and VMware can provide virtualization technologies, the main difference between them is how they are implemented and what they are used for.

KVM (Kernel-based Virtual Machine) is an open-source virtualization technology that relies on the Linux kernel for virtualization support. KVM allows multiple virtual machines (VMs) to run simultaneously on the same physical host, each of which can run its own operating system and applications. KVM can run on x86 and ARM architecture processors. It supports hardware-accelerated virtualization and provides high performance and scalability.

VMware virtualization allows virtual machines to run on multiple operating systems (e.g., Windows, Linux, macOS, etc.). You are able to run VMware virtual machines on the same physical host or migrate VMs between different physical hosts since VMware provides a rich set of management tools and APIs to help you manage virtualized environments.

Why need to migrate Linux VM to KVM

There are several reasons why someone might want to migrate their Linux virtual machines (VMs) from VMware to KVM:

  • Cost: KVM is an open-source hypervisor, which means it is free to use and there are no licensing fees. This can be attractive to organizations who are looking to reduce their costs.
  • Performance: KVM is known to provide better performance than VMware in certain scenarios, especially when it comes to I/O-intensive workloads. KVM has a smaller overhead, which means it can allocate more resources to VMs, resulting in better performance.
  • Flexibility: KVM is part of the Linux kernel, which means it is tightly integrated with the operating system. This provides a high degree of flexibility and control over VMs, allowing users to customize their configurations and settings to meet their specific needs.
  • Security: Because KVM is open-source, it is auditable and transparent. This means that security vulnerabilities can be quickly identified and addressed by the community. Additionally, KVM supports the use of Security-Enhanced Linux (SELinux), which provides an additional layer of security.
  • Vendor lock-in: By using VMware, organizations may become dependent on a single vendor and their proprietary technology. By migrating to KVM, organizations can avoid vendor lock-in and have more control over their virtualization infrastructure.

Overall, the decision to VMware to KVM migration will depend on the specific needs and requirements of an organization. However, the above factors may be considered when evaluating the benefits of making the migration.

Precaution of migrating Linux VM from VMware to KVM

Migrating Linux virtual machines (VMs) from VMware to KVM requires careful planning and execution to ensure a successful migration. And here are some precautions to consider:

  • Compatibility: Before migrating, it is important to ensure that the VMs being migrated are compatible with KVM. This includes verifying that the guest operating system is supported and that any applications or services running on the VM can be migrated successfully.
  • Backup: It is recommended to create a backup of the VMs before migrating. This will allow you to revert to the original VMs in case of any issues during the migration process.
  • Testing: Before migrating, it is important to test the migration process in a test environment to identify any potential issues or problems. This allows you to address these issues before migrating production VMs.
  • Configuration: KVM has different configuration settings than VMware, so it is important to review and update the configuration settings of the VMs being migrated to ensure they will work properly on KVM.
  • Networking: KVM uses a different networking model than VMware, so it is important to review and update the network settings of the VMs being migrated to ensure they can communicate properly after the migration.
  • Performance: It is important to monitor the performance of the VMs after the migration to ensure they are running optimally on KVM. This includes monitoring CPU utilization, memory usage, and disk I/O to identify any potential performance issues.

Overall, migrating Linux VMs from VMware to KVM requires careful planning and execution to ensure a successful migration. By taking these precautions, you can minimize the risk of encountering issues during the migration process and ensure a smooth transition to KVM.

How to migrate Linux VM from VMware to KVM (2 ways)

VMware vSphere is a fantastic virtualization solution that has drawn thousands of customers, and KVM is also gaining popularity. If your IT system has two hypervisors and you need to migrate Linux VM to KVM, here are two specific ways for you:

Migarte VM from VMware to KVM with virt-v2v

Step 1. Install virt-v2v package and its dependencies on the host.

# yum install virt-v2v

Step 2. Use the following command to convert the VMware Linux VMs, replacing vcenter.example.com / Datacenter / esxi with the path to the VMware vCenter and guestvm1 with the name of the VM you want to convert:

# virt-v2v -ic esx://vcenter.example.com/Datacenter/esxi guestvm1

Note: A URI escape must be included for the character DOMAIN%5cUSER if the vpx user name contains a backslash character, such as DOMAIN/USER. The%20 code must be used to enter spaces in the Datacenter name.

Step 3. Open your VMware vCenter server and authenticate to it. virt-v2v supports password authentication when connecting to VMware vCenter. You can enter the password during conversion or by using the-password-file option.

Note: Connecting to the VMware vCenter server will fail if it is not configured with a valid vCenter CA certificate, for instance if it utilizes a self-signed certificate. By adding ?no_verify=1 to the connection URI as shown below, it is possible to explicitly deactivate certificate checking in this situation:

... -ic vpx://esx.example.com?no_verify=1 ...

Step 4. Then check the conversion progress, a successful conversion outputs looks like the following:

Step 5. At last, confirm the VM has been imported correctly:

# virsh list –all

Migarte VM to KVM using qemu-img

To use qemu-img to migrate a Linux VM from VMware to KVM, you can follow these general steps:

Step 1. Convert the VMware virtual disk file (VMDK) to a raw image format that KVM can understand using the qemu-img command. To do this, run the following command:

qemu-img convert -f vmdk source.vmdk -O raw destination.img

Replace source.vmdk with the path to your VMDK file and destination.img with the desired name and path for the raw image file.

Step 2. Copy the resulting raw image file to the KVM host. You can use any method you prefer for this step, such as SCP or an external drive.

Step 3. Create a new virtual machine in KVM and specify the raw image file as the virtual disk. You can use a GUI tool like virt-manager or create the VM directly from the command line.

Step 4. Boot the new virtual machine in KVM and install any necessary drivers if required.

Note: This is a general guide, and the exact steps may vary depending on your specific setup and requirements. Additionally, you may need to perform additional configuration or troubleshooting steps to ensure the migrated VM works properly in KVM.

How to migrate VMware VM securely and rapidly

To ensure that your data is not misplaced or lost during the migration process, it's important to take precautions such as backing up your virtual machines. This can help you avoid potential headaches down the line and ensure that your data is safe and secure throughout the migration process.

AOMEI Cyber Backup - a VMware backup software provides a convenient and reliable backup and recovery solution for VMware VMs. It simplifies VM management and protects data security. With its intuitive interface, you can easily backup and restore numerous virtual machines.

Restoring a new VM directly from a backup eliminates the complex re-configuration and re-installation, thus saving time and effort and minimizing the risk of data loss during migration. And you can also enjoy the benefits including:

Auto backup - Run VM backups automatically that greatly simplify VM backup and management. Retention policy - Delete old backup files automatically and save storage space. Batch VM Backup - Batch backup large numbers of VMs on a standalone ESXi host or managed by vCenter Server and notify you by email. Easy to restore - Easily restore a VM to another datastore or host without any complicated configuration.

Please get and set up the agentless backup program - AOMEI Cyber Backup and you can use the following free trial for 30 days:

Download Free TrialVMware ESXi & Hyper-V
Secure Download

Then I'll go into great detail in next section that how to use AOMEI Cyber Backup to quickly backup and restore multiple virtual machines.

Concise steps to back up VMware virtual machines:

Step 1. Access to AOMEI Cyber Backup web client, select Source Device, click VMware >> +Add VMware Device >> Add vCenter or Standalone ESXi. And then click to Bind Device.

Step 2. Create Backup Task: Navigate to Backup Task >> Create New Task. Then select VMware ESXi Backup for Backup Type. After that, set the Task Name, Device, Target, Schedule and Cleanup according to your need.

  • Task Name: Specify your task name as you want.
  • Device Type: Select the VM on the host that you want to back up.
  • Target storage: Select to back up to a local path or a network path.
  • Schedule Type: Choose to perform full backup/differential backup/incremental backup, and automate execution daily/weekly/monthly.
  • Backup Cleanup: Set up a retention policy to remove old backup files automatically, which saves your costs and efforts.

Step 3. Click Start Backup and choose Add the schedule and start backup now or Add the schedule only.

Easy steps to restore from backup:

Step 1. After the backups are completed, you can easily restore VM from backup. Navigate to Backup Task, and click and select Restore to start the VMware data recovery task.

Step 2. Select the VM you want to restore, then click OK.

Step 3. You can choose to restore to original location or new location. If you choose to Restore to new location, you can change the RAM and Vital Processor according to your needs.

  • Restore to: You can choose Restore to new location to avoid re-configuring the new VM.
  • Select Target: Specify the target host and datastore as you want.
  • Others:You can also choose the storage of data, and set its RAM and Virtual Processor.

Conclusion

Migrating Linux virtual machines (VM) from VMware to KVM involves transferring the VM's disk image and configuration files to the KVM host. There are several tools available to assist with this process, including virt-v2v and qemu-img. Additionally, it may be necessary to modify the VM's configuration files to ensure compatibility with the KVM environment. It is important to make VM backups before migration which minimizes downtime and avoids any potential data loss or configuration issues.