DevOps & Platform Eng

VMware to KVM Migration: Pitfalls & Fixes

Migrating a VM from VMware to KVM isn't just about copying files. It's a delicate dance with potential pitfalls that can leave your systems inoperable.

{# Always render the hero — falls back to the theme OG image when article.image_url is empty (e.g. after the audit's repair_hero_images cleared a blocked Unsplash hot-link). Without this fallback, evergreens with cleared image_url render no hero at all → the JSON-LD ImageObject loses its visual counterpart and LCP attrs go missing. #}
A stylized graphic representing the transfer of a virtual machine from one hypervisor to another, with gears and data streams.

Key Takeaways

  • Disk conversion with `qemu-img` is critical; ensure you handle split or stream-optimized VMDKs correctly.
  • Guest OS drivers (especially virtio) are paramount for successful booting and networking on KVM.
  • Reconciling hardware emulation (BIOS/UEFI, controllers, NICs) between VMware and KVM is essential to avoid boot failures.
  • Repairing `initramfs` and updating kernel modules may be necessary if the guest OS doesn't recognize the new disk controller on KVM.

VMware to KVM migration: solved.

Or is it? My junior engineer asked me last week how to move a VM from VMware to KVM without losing data or, you know, breaking everything. It’s a fair question. It’s not that the tools don’t exist; it’s that the failure points are often hidden. We’re talking about disk format quirks that make qemu-img choke, firmware mismatches that send your bootloader into a tailspin, and driver assumptions baked so deep into the guest OS that they flat-out refuse to acknowledge their new reality. Success here isn’t about brute force; it’s about understanding the subtle mechanics.

And make no mistake, those mechanics matter. You’ve got to grasp how disk conversion actually works under the hood, how bootloaders decide which device is the “root” when the hardware context changes, and why those pesky paravirtualized drivers are essential, even when you think you’ve abstracted away all the hardware details. This isn’t just a cp command and a prayer.

The Disk: More Than Just Bits

The absolute, non-negotiable, most critical step in any of these migrations is dealing with the disk. We’re talking about transforming VMware’s ubiquitous .vmdk into KVM’s preferred .qcow2. The magic behind this transformation? qemu-img, a surprisingly capable utility that uses QEMU’s block layer. It reads your source format, grabs every allocated block, and then meticulously writes it into a new image file using a clever copy-on-write metadata structure. This isn’t just for show; it’s what enables .qcow2 to do things like snapshots, compression, and sparse allocation — features that your plain-Jane raw images are missing entirely.

Here’s the basic command:

qemu-img convert -f vmdk -O qcow2 /path/to/vm-disk.vmdk /path/to/vm-disk.qcow2

That -f vmdk flag? Crucial. It explicitly tells qemu-img what it’s dealing with. Don’t rely on autodetection, especially with those pesky stream-optimized or split disks. You must point qemu-img to the descriptor file, not the -flat parts. And trust me, if your disk is split into 2GB chunks, pointing it to the wrong file is a quick way to get a cryptic error message.

Once you’ve run the conversion, you’d do well to verify it. qemu-img info vm-disk.qcow2 should show you a virtual size that matches your original VM disk and a disk size that’s significantly smaller. If the latter is true, your .qcow2 conversion is working as intended, efficiently using space.

“Migration isn’t about copying bits — it’s about preserving context.”

Now, about those stream-optimized .vmdk files. You’ll know you’ve hit one when qemu-img gives you an “Invalid argument” error. The fix? You have to re-serialize it first into a flat format before you can even think about converting it to .qcow2. It’s an extra step, but it beats staring at a failed migration for hours.

Why .qcow2 over raw? It’s simple: features. Snapshots are invaluable. Compression saves you disk space. Encryption adds a layer of security. Sparse allocation means you’re not wasting gigabytes on empty blocks. Unless you’ve got a very specific, low-latency I/O requirement or you’re directly piping to LVM, .qcow2 is the way to go.

The Context: Beyond the Disk Image

A virtual machine is so much more than just its disk. It’s the emulated CPU, the memory layout, the firmware that boots it, and the device models that present hardware to the guest. And this is where VMware and KVM often diverge, leading to those frustrating boot failures and driver issues. VMware tends to favor traditional BIOS firmware, IDE/SATA controllers, and e1000/vmxnet3 NICs. KVM, on the other hand, often defaults to UEFI, virtio-blk, and virtio-net. Faster, yes, but only if your guest OS actually has the drivers for it.

And that’s the kicker: if the guest OS you’re migrating doesn’t have virtio drivers installed, it won’t even see the disk or the network. Kernel panics on boot are practically guaranteed. So, when you’re setting up your new KVM VM, start by mirroring the original hardware as closely as possible. Use virt-install or virsh define and carefully craft your XML domain definition. Pay attention to the <model type='virtio'/> for interfaces. It’s great for CPU savings, but if the guest was running on VMware with an e1000 card, it’s probably missing the virtio-net drivers, and your VM will just sit there, silently refusing to boot.

Drivers: The Ghost in the Machine

When things go wrong post-migration, it’s almost always about drivers or boot configuration. If your VM boots but networking or disk I/O is erratic, you’re likely facing a paravirtualized driver issue. The fix often involves booting into a rescue environment, repairing the initramfs (the initial RAM file system that contains the kernel modules needed to mount the root filesystem), and explicitly loading the correct drivers. Sometimes, /dev/sda on VMware becomes /dev/vda on KVM. If your initramfs isn’t updated with the right modules, your system will get lost looking for the disk it expects. This happened to me once, and it cost me two hours because I wasn’t looking in the right place – the initramfs configuration.

Who’s actually making money here? This is a bit of a trick question, isn’t it? The companies selling virtualization solutions (VMware, Red Hat with KVM/OpenShift, Microsoft with Hyper-V) are in the business of locking you into their ecosystems. Migrating away from VMware to KVM often means shedding licensing costs. So, KVM’s success is directly tied to the ongoing cost of VMware’s dominance. It’s less about a new product generating revenue and more about commoditizing infrastructure.

The Real Cost of ‘Free’

KVM, being open-source and part of the Linux kernel, is free in terms of licensing. But ‘free’ rarely means ‘no cost’. The engineering effort required to manage KVM, especially at scale, is substantial. Companies that have heavily invested in VMware’s tooling and support are likely hesitant to jump ship unless the cost savings are truly astronomical. The complexity of migrating, as outlined here, is a significant barrier. It requires specialized knowledge, often from engineers who understand both VMware’s internals and the intricacies of qemu, <a href="/tag/libvirt/">libvirt</a>, and Linux system administration. So, while KVM offers a path to cost reduction, the upfront investment in time, expertise, and potential downtime means it’s a strategic decision, not just a technical one.


🧬 Related Insights

Frequently Asked Questions

What does VMware to KVM migration actually involve? It involves converting the virtual machine’s disk image format from VMware’s VMDK to KVM’s QCOW2 and ensuring the VM’s configuration (CPU, memory, firmware, drivers) is compatible with the KVM hypervisor to prevent boot and driver issues.

Will this process affect my data integrity? If performed correctly, the data integrity should be preserved. The primary risks to data integrity come from incomplete disk conversions or filesystem corruption during a failed boot process post-migration. Careful verification at each step is key.

Is it possible to migrate a running VM from VMware to KVM? Live migration from VMware to KVM is not natively supported. The process typically involves shutting down the VM, performing the disk conversion, configuring the VM on KVM, and then booting it on the new hypervisor.

Is KVM a direct replacement for VMware? KVM is a hypervisor technology, similar in function to VMware’s ESXi. However, a complete replacement often involves migrating to a broader virtualization platform like OpenShift Virtualization (which uses KVM) or managing KVM through tools like oVirt or Proxmox VE, as KVM alone is a component rather than a full-stack solution.

Written by
DevTools Feed Editorial Team

Curated insights, explainers, and analysis from the editorial team.

Frequently asked questions

What does VMware to KVM migration actually involve?
It involves converting the virtual machine's disk image format from VMware's VMDK to KVM's QCOW2 and ensuring the VM's configuration (CPU, memory, firmware, drivers) is compatible with the KVM hypervisor to prevent boot and driver issues.
Will this process affect my data integrity?
If performed correctly, the data integrity should be preserved. The primary risks to data integrity come from incomplete disk conversions or filesystem corruption during a failed boot process post-migration. Careful verification at each step is key.
Is it possible to migrate a running VM from VMware to KVM?
Live migration from VMware to KVM is not natively supported. The process typically involves shutting down the VM, performing the disk conversion, configuring the VM on KVM, and then booting it on the new hypervisor.
Is KVM a direct replacement for VMware?
KVM is a hypervisor technology, similar in function to VMware's ESXi. However, a complete replacement often involves migrating to a broader virtualization platform like OpenShift Virtualization (which uses KVM) or managing KVM through tools like oVirt or Proxmox VE, as KVM alone is a component rather than a full-stack solution.

Worth sharing?

Get the best Developer Tools stories of the week in your inbox — no noise, no spam.

Originally reported by dev.to

Stay in the loop

The week's most important stories from DevTools Feed, delivered once a week.