How to Migrate a Virtual Machine
In this article
- What Virtual Machine Migration Means
- How VM Migration Works
- Choosing the Right Migration Method
- Step-by-Step: Cold Migration (Generic)
- Step-by-Step: Live Migration (VMware vMotion Example)
- Common Problems and How to Avoid Them
- Costs, Safety, and Best Practices
- Alternatives to Traditional Migration
- Frequently Asked Questions
To migrate a virtual machine, you copy its virtual disk files and configuration to a new host, then register the VM there — or use a live migration tool that moves it without downtime. The exact steps depend on your hypervisor (VMware, Hyper-V, KVM, etc.), but the core process involves exporting or copying the VM’s files, converting formats if needed, and importing them on the destination.
What Virtual Machine Migration Means
Virtual machine (VM) migration is the process of moving a VM from one physical server (host) to another, or between storage systems. It’s a routine task in data centers for hardware maintenance, load balancing, disaster recovery, or cloud adoption. Unlike physical server migration, VM migration can often be done with minimal or zero downtime because the VM’s state is captured and transferred while it continues running.
There are two main types:
- Cold migration – The VM is powered off before moving. This is simpler and safer but requires downtime.
- Live migration – The VM keeps running while its memory and disk state are copied to the destination, then a brief switchover occurs. This is used for zero-downtime moves.
How VM Migration Works
At a technical level, migration involves transferring the VM’s virtual disk (the file that acts as its hard drive) and its configuration (CPU, RAM, network settings). For live migration, the hypervisor copies memory pages to the destination while the VM runs, tracks changes to those pages, and then performs a final “stop-and-copy” to sync the last changes. The VM is paused for a fraction of a second, then resumed on the new host.
For cold migration, you simply shut down the VM, copy the disk files (e.g., .vmdk for VMware, .vhd/.vhdx for Hyper-V, .qcow2 for KVM), and register the VM on the new host. If the destination uses a different hypervisor, you may need to convert the disk format using tools like qemu-img or StarWind V2V Converter.
Choosing the Right Migration Method
Your choice depends on your environment and requirements:
- Same hypervisor, same host type – Use the built-in migration feature (e.g., vMotion for VMware, Live Migration for Hyper-V).
- Different hypervisors – Use a conversion tool or export/import in a standard format like OVF/OVA.
- To the cloud – Use cloud provider tools like Azure Migrate or AWS Server Migration Service, or manually upload disk images.
- Physical to virtual (P2V) – Not strictly VM migration, but often needed when moving from physical servers; tools like Disk2vhd or VMware vCenter Converter can help.
For a one-time move, cold migration is often easiest. For ongoing flexibility, live migration is essential.
Step-by-Step: Cold Migration (Generic)
- Shut down the VM gracefully via the guest OS.
- Copy the VM files to the destination host or shared storage. This includes the disk file(s) and the configuration file (e.g., .vmx, .xml, .conf).
- Convert disk format if the destination hypervisor uses a different format (e.g., VMDK to VHDX).
- Register the VM on the destination by importing the configuration file or creating a new VM and attaching the copied disk.
- Power on the VM and verify networking, storage, and applications.
Step-by-Step: Live Migration (VMware vMotion Example)
- Ensure prerequisites: shared storage (or vMotion with storage), compatible CPUs, and network connectivity.
- Initiate migration from the vSphere client: right-click the VM and select “Migrate.”
- Choose destination host and storage.
- Select migration type – “Change both compute resource and storage” if moving both.
- Review and finish – The VM moves without downtime.
Hyper-V Live Migration is similar, using Failover Clustering or shared storage.
Common Problems and How to Avoid Them
- Incompatible CPU features – If the destination host has a different CPU generation, the VM may fail to start. Use Enhanced vMotion Compatibility (EVC) in VMware or ensure same CPU family.
- Disk format mismatch – Always convert formats correctly; a raw disk copy may not boot.
- Network configuration changes – The VM’s MAC address may change, causing licensing or network issues. Keep the same MAC or update the OS accordingly.
- Storage path changes – Update the VM’s configuration to point to the new disk location.
- Licensing issues – Some software licenses are tied to hardware; reactivation may be needed.
Costs, Safety, and Best Practices
Migration itself is free if you use built-in tools, but you may need to budget for storage space on the destination, bandwidth for copying large disk files, and potential downtime. Always back up the VM before migration, especially for cold migrations. Test the migration on a non-production VM first. For live migration, ensure the network is reliable and has enough bandwidth to avoid timeouts.
Safety tips:
- Never delete the source VM until the destination is fully verified.
- Use checksums to verify file integrity after copying.
- Document the VM’s configuration (IP, hostname, services) before migration.
- For sensitive data, consider encryption during transfer.
Alternatives to Traditional Migration
If you’re moving to a different platform, consider these alternatives:
- Replicate the workload – Instead of moving the VM, rebuild the application on the new host and sync data.
- Containerization – Convert the VM to a container image (e.g., with tools like img2docker) for a more portable deployment.
- Disaster recovery replication – Use replication tools to continuously copy the VM to a secondary site, then failover.
Frequently Asked Questions
Can I migrate a VM between different hypervisors?
Yes, but you need to convert the disk format. Tools like qemu-img can convert VMDK to VHDX or QCOW2. The VM’s guest OS may need driver updates for the new virtual hardware.
Does live migration require shared storage?
Not necessarily. VMware vMotion can migrate without shared storage using “storage vMotion,” and Hyper-V Live Migration can work with local storage if you use SMB shares or Replication. However, shared storage simplifies the process.
How long does a VM migration take?
It depends on the disk size, network speed, and whether it’s live or cold. A small VM (20 GB) on a gigabit network can take minutes; a large VM (1 TB) could take hours. Live migration is faster for the user because downtime is minimal, but the total transfer time is similar.
What is a P2V migration?
Physical-to-virtual (P2V) migration converts a physical server into a VM. Tools like VMware vCenter Converter or Disk2vhd capture the physical disk and create a virtual disk. It’s useful for consolidating old hardware.
Can I migrate a VM to the cloud?
Yes. Most cloud providers offer tools (e.g., Azure Migrate, AWS SMS) that automate the process. You can also manually upload a VHD or VMDK and import it as a custom image.
What should I do if the migrated VM won’t boot?
Check the disk format and configuration. Ensure the VM’s firmware type (BIOS/UEFI) matches the original. Boot from a rescue CD and repair the boot loader if needed. Also verify that the virtual hardware (e.g., SCSI controller) is compatible.