VMFS Recovery™
Recover data from damaged or formatted VMFS disks or VMDK files
Recover data from damaged or formatted VMFS disks or VMDK files
Last updated: May 13, 2025

How to Copy ESXi VM

Virtualization plays a critical role in ensuring flexibility, scalability, and efficient resource utilization. VMware's ESXi, a leading hypervisor, allows businesses to run multiple virtual machines (VMs) on a single physical server, improving hardware efficiency and operational agility. However, as organizations grow and adapt, there often arises a need to duplicate or transfer these VMs to optimize performance, increase fault tolerance, or facilitate migration to different infrastructures.

In this article, we will explore the step-by-step processes involved in copying an ESXi VM and transferring a VM from one ESXi host to another. Whether you're a system administrator aiming to optimize your virtual environment or just exploring ESXi capabilities, this guide will walk you through every nuanced step, ensuring a seamless and efficient migration process.

Understanding VM Copying in VMware ESXi

Cloning vs. Copying vs. Migrating

In virtualization, it's important to distinguish between cloning, copying, and migrating as they serve unique purposes and scenarios:

  • Cloning: Creating a clone of a VM involves making an exact replica of the virtual machine. This is particularly useful in testing and development where you need an isolated environment that mirrors production settings. Cloning preserves the VM's state at the time of creation, allowing for safe experimentation without affecting the original system.
  • Copying: Copying a VM generally refers to duplicating its virtual disk files and configuration settings. Unlike cloning, which usually involves creating a new VM entry in the management console, copying might simply result in the same VM being available in a different location or on another host. This process is typically manual and can involve tools or command-line operations to move files between storage units.
  • Migrating: Migration is the process of moving a VM from one ESXi host to another, which can be done live or offline (vMotion for live migrations). Live migration ensures that the VM continues to run without interruption, maintaining ongoing workloads during the transfer. Migration is suitable for load balancing, hardware maintenance, or minimizing downtime during upgrades.

When and Why to Copy a VM

Copying VMs is a strategic task undertaken for several reasons:

  • Disaster Recovery: Having copies of VMs stored in different locations ensures that your systems can be quickly redeployed in the event of a catastrophic failure, minimizing data loss and downtime.
  • Load Optimization: By copying VMs to other hosts, you can balance workloads more effectively, helping to optimize resource usage without overloading a single server.
  • Testing and Development: Copying VMs allows for rapid deployment of testing environments identical to production, facilitating troubleshooting, updates, or new feature testing in a risk-free setup.

Copying VMs is invaluable when setting up environments that need to mirror each other quickly, enabling admins to scale and manage resources flexibly in dynamic IT landscapes.

Licensing and Compatibility Considerations

When planning to copy VMs, keep the following factors in mind to avoid complications:

  • Licensing: Ensure that your infrastructure's licensing agreements allow for copying and running duplicate VMs. Different versions of VMware ESXi and associated management tools like vSphere have specific licensing considerations that must be addressed to remain compliant.
  • Compatibility: VMs have dependencies on both hardware and software configurations, which may differ between ESXi hosts. It’s crucial to verify that the target host supports the VM's current hardware version of the virtual hardware it requires, including CPU types, memory allocation, and networking configurations.
  • Software Dependencies: It's essential to ensure that any software running inside the VM, including OS and applications, remain licensed and functional across different hosts or environments. Compatibility checks and updates may be necessary to maintain operational integrity.
VM Data Recovery: Ensuring that your VM data can be recovered in the event of a disaster is crucial for maintaining business continuity. It’s important to regularly back up your VM data and test recovery processes to ensure they work as expected. Utilize robust recovery solutions designed specifically for virtualized environments to handle everything from file corruption to failed upgrades. Proactively managing these elements can greatly minimize downtime and data loss.

Copy VM from One ESXi Host to Another: All Methods Explained

Option 1: SCP or WinSCP for File-Level Copy

Using SCP (Secure Copy Protocol) or WinSCP is a straightforward method for transferring VM files directly from one ESXi host to another at the file system level. This approach involves using command-line tools or a friendly GUI application like WinSCP to login to the ESXi host and manually copy the VM's files to the target host. Although effective for smaller environments or standalone hosts, it's important to handle the VM’s power state and ensure consistent network configurations following the transfer. This method may involve downtime as the VM needs to be powered off during the file transfer.

Option 2: Using VMware vCenter and vMotion

For enterprises with VMware vCenter, leveraging vMotion provides a seamless migration experience. vMotion allows live migration of running VMs between hosts with no downtime, maintaining network settings, and system states. This feature is especially useful in environments aiming for minimal intervention and is part of a larger load balancing or maintenance strategy. To use vMotion, both hosts need to be managed by the same vCenter server, and configurations like shared storage or VM networking setup need to be correctly configured.

Option 3: Export and Import OVF/OVA Templates

Creating Open Virtualization Format (OVF) or Open Virtual Appliance (OVA) templates of your VMs is a versatile way to move them between hosts. This involves exporting a VM into an OVF/OVA template, which can then be imported into another host. This method is beneficial for transferring VMs to different datacenters or clouds and ensures that all VM configurations are preserved during transit. It’s an excellent option for transporting VMs across disconnected environments or when setting up a new host from scratch.

Option 4: Shared Datastore Method

If your ESXi hosts have access to the same shared datastore (such as an NFS or iSCSI storage setup), you can directly move VMs between hosts by simply changing their registration location in the VMware vSphere client. This method doesn’t require physical file movement and can often be done with minimal downtime. The shared datastore method is efficient in environments designed with interoperability between hosts and streamlined shared storage access.

Option 5: USB or External Storage Transfer

For offline environments or scenarios with limited network bandwidth, using USB drives or external storage devices can be an effective way to transfer VMs. This method involves copying VM files onto an external storage medium, physically transporting it to the target host, and then copying the files onto the new host’s datastore. While more manually intensive, this approach is useful for sites lacking high-speed network connections or when devices need to be moved between geographically distant locations.

Note: VMware Cold migration involves moving a powered-off VM between hosts or datastores. This method is useful when you need to transfer VMs without requiring shared storage or high-speed networking capabilities. Cold migrations do not support live user sessions, so it's best suited for maintenance windows or non-critical applications. Ensure compatibility between the source and target hosts to avoid migration issues.

Step-by-Step: Copying a VM Between ESXi Hosts Using SCP

Step 1: Enable SSH and Prepare Hosts

To utilize SCP for VM transfer, you must first ensure that both source and target ESXi hosts have SSH access enabled:

  1. 1. Enable SSH: Log into the ESXi host web client for both the source and target hosts. Navigate to Manage > Services. Locate TSM-SSH and click Start to enable SSH service. Repeat this on both hosts.
  2. 2. Check Network Configuration: Verify that both hosts are on the same network segment or have necessary routing in place to communicate with each other. Ensure the firewall rules do not block SSH connections.
  3. 3. Validate Storage Space: Check that the target host has enough free disk space on its datastore to accommodate the complete VM, including all associated disk files.

Step 2: Locate the VM Files (VMDK, VMX)

With SSH access set up, proceed to identify the files corresponding to the VM:

  1. 1. Log into the Source Host: Use an SSH client (like PuTTY or directly via terminal) to log into your ESXi host using its IP address and administrator credentials.
  2. 2. Navigate to the VM Directory: Typically, VM files are stored in /vmfs/volumes/datastore_name/vm_directory/. Identify the relevant datastore and navigate to it using cd.
  3. 3. Identify Essential Files:
  • VMDK Files: These are the virtual disks of the VM.
  • VMX File: It contains the configuration for the VM.

Use the ls command to confirm the presence of these files.

Step 3: Use SCP or WinSCP to Transfer

With the required files identified, use SCP to transfer them:

  1. 1. Command-Line SCP Transfer:
  • Initiate an SCP command from a terminal on your local machine or directly from the ESXi SSH session.
  • The SCP command may look like:
scp /vmfs/volumes/datastore_name/vm_directory/* root@target_host_ip:/vmfs/volumes/target_datastore_name/target_vm_directory/
  • Enter the password for the SSH connection when prompted.
  1. 2. WinSCP GUI Alternative:
  • Open WinSCP and establish a session with the source host by entering its credentials.
  • Navigate to the directory containing the VM files.
  • Select the files and drag them to the corresponding directory in the target host session.
  • Ensure the target directory mirrors the source's file structure.

Note: Transferring large files over SCP can take considerable time depending on network conditions.

Step 4: Register the VM on the Target Host

Once files are transferred to the target host, you’ll need to register the VM:

  1. 1. Access the Target Host’s Web Interface: Using a browser, log into the ESXi web client of the target host.
  2. 2. Browse the Datastore: Navigate to Storage and select the appropriate datastore where the VM files were copied.
  3. 3. Locate the VMX File: Within the datastore browser, find the directory containing the copied VM files and identify the .vmx file.
  4. 4. Register the VM:
  • Right-click the .vmx file and select Register VM.
  • Follow the registration wizard, maintaining the current VM settings unless specific changes are needed.
  1. 5. Power On the VM: After registration, go to the Virtual Machines tab, locate your registered VM and power it on. Verify its operation by checking system logs and configuration settings.
How to Recover VMware Virtual Machine: Recovering a deleted VMware virtual machine can be straightforward if prepared in advance. Regularly scheduled snapshots and backups are essential in ensuring you can recover VMs quickly and with minimal data loss. Additionally, understanding the structure of VMFS can help you use specialized tools to recover misplaced or corrupted VM files efficiently.

Using vCenter to Move or Clone VMs Between Hosts

Step-by-Step: vMotion for Licensed Environments

vMotion, a flagship feature of vSphere, allows for the live migration of virtual machines across hosts with zero downtime. The following steps outline how to execute vMotion in environments where vCenter is set up and licensed:

  1. 1. Verify Prerequisites: Ensure both ESXi hosts are managed by the same vCenter server, are networked for vMotion, and have access to shared storage necessary for the VMs.
  2. 2. Open vSphere Client: Log into your vCenter Server using the vSphere Client.
  3. 3. Select the VM: Navigate to the inventory view, select the VM you wish to move, right-click on it, and choose Migrate.
  4. 4. Choose Migration Type: In the migration wizard, select Change Host.
  5. 5. Choose Destination Host: Select the target host where you want the VM to move. Ensure the host meets all compatibility checks before proceeding.
  6. 6. Confirm Resource and Compatibility Checks: vCenter will perform checks to ensure the VM’s resource requirements can be met by the target host. Review the results and resolve any issues, if necessary.
  7. 7. Finalize Migration: Approve the migration, and vCenter will handle the process while the VM remains operational. Monitor the status through the task list to confirm successful move completion.

Using vSphere Client to Clone a VM to Another Host

Cloning a VM using the vSphere Client involves creating a replica of a VM on the same or different host:

  1. 1. Login to vSphere Client: Connect to your vCenter environment with the vSphere Client.
  2. 2. Select the VM to Clone: In the inventory, locate and select the VM you want to clone. Right-click on it and choose Clone > Clone to Virtual Machine.
  3. 3. Specify Clone Details: In the clone wizard, provide a name for the cloned VM and choose a destination folder or datacenter where the clone should reside.
  4. 4. Choose Destination Host and Datastore: Select the target host which will house the cloned VM and the datastore for its files. Ensure host compatibility for seamless operation.
  5. 5. Customize the Clone as Needed: You can opt to customize the cloned VM’s hardware configuration at this stage. Adjust CPU, memory, and other settings as required.
  6. 6. Review and Complete: Review the clone settings in the final step of the wizard. Confirm the options and initiate the cloning process.
  7. 7. Monitor Progress: The cloning activity will be listed in tasks—monitor until completion. After cloning, the new VM will appear in the specified location, ready for use.
Migrate from VMware to Hyper-V: Transitioning from VMware to Hyper-V requires careful planning to ensure compatibility and continuity. Begin with a thorough inventory of VMs and their configurations. Utilize conversion tools that facilitate seamless transitions, ensuring all data and settings are accurately migrated. Testing the converted environment is crucial to resolving potential issues before going live.

Validation After Copy

Power On and Test the Copied VM

Once the VM has been successfully copied to the target host, the first step in the validation process is to power it on and conduct a thorough test. This involves:

  1. 1. Power On the VM: Use the ESXi or vSphere web client to start the VM. Monitor the boot process to ensure it comes online without errors.
  2. 2. Check System Logs: Access system logs within the VM's operating system and the ESXi host to ensure there are no errors or warnings that might indicate configuration issues.
  3. 3. Functional Testing: Run any necessary applications or services on the VM to confirm they are operating as expected. It's important to check for performance consistency compared to the source VM.
  4. 4. Connectivity Testing: Verify network connectivity by checking if the VM can communicate with other devices and servers as required. This includes pings, accessing shared resources, and ensuring that any hosted services are accessible.

Check MAC Addresses, UUIDs, and IP Conflicts

VM copying can occasionally lead to conflicts in network configurations due to shared identifiers. It's crucial to:

  1. 1. MAC Address Verification: On ESXi, each VM should have a unique MAC address. Verify this in the VM's network adapter settings and reconfigure if necessary to prevent network issues.
  2. 2. UUID Examination: VMs have unique UUIDs used for their identification across environments. Check both the BIOS and VM-level UUIDs, ensuring they don't conflict with existing VMs.
  3. 3. IP Address Conflicts: Ensure the VM's IP address configuration doesn’t clash with other devices on the network. If your network uses static IPs, you may need to assign a new IP, especially if the copied VM is intended to run simultaneously with the original.

Reconfigure VM Settings if Needed

After identifying and addressing any conflicts, consider any necessary adjustments to the VM's configuration to suit the target environment:

  1. 1. Hardware Adjustments: Depending on the target host's resources and intended use, you might need to tweak the VM’s hardware settings, such as CPU, memory, or disk resources.
  2. 2. Network Configuration: Adjust network settings like VLAN assignments or any custom networking scripts to ensure they align with the target environment's topology.
  3. 3. Guest Operating System Settings: If the VM operates in a different networking setup, update OS-level configurations such as DNS settings, firewall rules, or integration with active directory services.
Convert VMware to Hyper-V: The process of converting VMware virtual machines to Hyper-V involves using tools specifically designed for virtualization conversion. These tools assist in maintaining the integral configurations of VMs, such as networking and storage options, during the conversion. It’s beneficial to run conversions during times of low activity to minimize disruption and verify functionality within the new environment beforehand.

Common Errors and How to Fix Them

SCP Permission Denied or Timeouts

When using SCP to transfer VM files, encountering permission denied errors or timeouts can disrupt the process:

  1. 1. Permission Denied:
  • Root Access: Ensure that the SSH command is executed with root access. Some ESXi hosts may require enabling root login over SSH.
  • File Permissions: Verify that the user has the necessary permissions to access the files. Correct any permissions issues using chmod or chown commands on the source host.
  1. 2. Timeout Issues:
  • Network Connectivity: Check the network connection between the source and target hosts. Latency or instability in the network can cause timeouts.
  • SCP Session Settings: For stable transfers, ensure settings limit command execution time. Consider using -C (compression) to potentially speed up transfers.

Missing VMX or VMDK Files

Occasionally, necessary VM configuration or disk files might be missing, causing operational issues:

  1. 1. Verify File Existence:
  • Double-check the source directory to ensure all relevant VMX and VMDK files were identified and included in the transfer.
  • Use ls to confirm the presence of expected files in the VM directory on the source host.
  1. 2. Restore from Backup:
  • If files are indeed missing, and you have a backup of the VM, restore the necessary files from the backup location to the source directory.
  1. 3. Correct Path Issues:
  • Ensure that the right paths are specified during SCP, particularly in nested directory structures, to avoid omitting critical files during copying.

Failed to Register or Power On the VM

If attempting to register or boot the VM on the target host fails, several factors could be responsible:

  1. 1. Compatibility Issues:
  • Confirm that the target host supports the CPU, memory, and network configurations specified in the VMX file. Adjust settings if needed to match the host's capabilities.
  1. 2. File Corruption:
  • Re-transfer the VM files if files were corrupted during copying. Verifying checksum values before and after transfer can help ensure data integrity.
  1. 3. Incorrect Registration Process:
  • Double-check the VMX file path and registration process in the host's management interface. Manual entry errors might prevent successful registration.
  1. 4. Log Review:
  • Analyze the error logs available in the ESXi client to diagnose specific errors preventing the power on. These logs can provide specific error codes or descriptions to guide troubleshooting.

Best Practices for Copying ESXi VMs

Use Checksums to Verify Integrity

Ensuring the integrity of VM files during transfer is critical to prevent data corruption:

  1. 1. Generate Checksums: Before initiating the transfer, generate checksums (e.g., MD5, SHA256) for all essential VM files like VMDK and VMX on the source host.
  2. 2. Verify Post-Transfer: After transferring the files to the target host, compute checksums again and compare them to the originals to confirm that no data was altered or corrupted during transit.
  3. 3. Automate the Process: Use scripts to automate checksum generation and verification, reducing human error and speeding up the validation process for large-scale operations.

Maintain Clean VM States Before Copy

Copying VMs in an optimal state avoids unnecessary complications and ensures operational consistency:

  1. 1. Shut Down or Suspend VMs: Before initiating a copy, ensure the VM is properly shut down or at least suspended. This helps avoid inconsistencies, particularly with file systems and application states.
  2. 2. Clear Temporary Files: Remove unnecessary temporary files or logs that might inflate the VM size, optimizing both the copying time and storage utilization.
  3. 3. Update Applications and OS: Make sure the virtualization tools, operating system, and key applications are up-to-date. This not only helps in maintaining security and functionality but also reduces potential incompatibility issues on the target host.

Document and Track Changes Across Hosts

Maintaining clear documentation ensures transparency and eases future management:

  1. 1. Record Configuration Details: Document the original configurations and settings such as network configurations, resources allocation, and any custom scripts or applications part of the standard VM setup.
  2. 2. Track Transfer Logs: Maintain detailed logs of the transfer activities, including the dates, sizes, and checksums, as well as any peculiarities or issues encountered during the copy process.
  3. 3. Inventory Management: Continuously update your VM inventory list with details of where each VM resides and their configurations post-transfer. This helps in establishing a clear picture of resource distribution across the host environment.
Hyper-V Clone VM: Cloning a VM in Hyper-V can be an efficient way to create identical environments for testing or deployment. Before starting, ensure that the VM you wish to clone is in a stable and updated state. Always verify that the target host has adequate resources to support the cloned VM. Cloning can help streamline the process of system testing or rollouts by providing a consistent and repeatable baseline.

Conclusion: Choosing the Right Method to Copy ESXi VMs

Copying VMware ESXi virtual machines between hosts can seem like a complex task, but with a clear understanding of the available methods and best practices, you can facilitate seamless migrations tailored to your organizational needs. When selecting the right method, consider the specific requirements of your environment:

  • For minimal downtime and dynamic environments, leveraging tools like vMotion through vCenter can provide an uninterrupted transition, ideal for live systems requiring constant uptime.
  • For simplicity and straightforward file transfers, using SCP or WinSCP offers a direct, albeit slightly manual, method that works well when dealing with smaller systems or isolated environments without shared storage infrastructure.
  • For ease of deployment in varied environments, exporting and importing VM templates via OVF/OVA files ensures consistent setup across varied infrastructures, particularly useful in pre-configured setups across different data centers.
  • For environments with shared storage, using shared datastores simplifies the process, allowing VM migration without moving large amounts of data over the network.

Ultimately, the choice depends on your infrastructure's capabilities, the criticality of the VMs in question, and the resources available. By evaluating the advantages and limitations of each method, and considering organizational goals and operational constraints, you can ensure that the VM copying process contributes to a robust and efficient IT strategy.

Related articles

FREE DOWNLOADVer 4.24, WinBUY NOWFrom $699

Please rate this article.
41 reviews