How to Fix Error “The Resource Is in Use” in VMware Clone

What to do if you got the VMware clone error: the resource is in use? What causes this error to occur? This article summarizes the answer for you.

Crystal

By Crystal / Updated on February 2, 2023

Share this: instagram reddit

Case: Error “The Resource is in use” while performing VMware clone

 

Hi all, I created a script to deploy several virtual machines from a single template. This script uses the “CloneVM_task” function. When I try to deploy 13 virtual machines with this script (or manually with vCenter function), I have the following error for the virtual machines clones number 9 and 10: “Resource already in use”. Do you have an idea?

- Question from communities.vmware.com

If you want to replicate some identical virtual machines for certain tests, or just want to deploy several virtual machines with the same resource allocation and configurations, then VMware clone is probably the best feature for you.

The VMware ESXi clone VM is a process in which you create exact copies of your original virtual machine. A virtual machine clone has the same hardware, software, and other configurations as the original virtual machine.

However, sometimes the cloning of a VM or removing a host from cluster might fail with error: The Resource is in use VMware clone, probably come with a port number.

The resource is in use VMware clone

What does the resource is in use VMware clone error mean, what causes it to happen, and how to resolve it? This article will show you the answer.

Cause of the VMware clone error “The resource is in use”

If you failed to clone a virtual machine from VMware vCenter and got the VMware clone error “The resource is in use”, the first thing you wanted to know for sure must be, what does this number refers to?

To troubleshoot, you can check the logs in the VM and the vCenter Server, which can help you to identify what is the resource that is being use. For example:

-->                      backing = (vim.vm.device.VirtualEthernetCard.DistributedVirtualPortBackingInfo) {
-->                         port = (vim.dvs.PortConnection) {
-->                            switchUuid = "d3 c1 00 50 98 4a 1c 57-ee 6e 99 92 5c d2 16 07",
-->                            portgroupKey = "dvportgroup-1712",
-->                            portKey = "400",
-->                            connectionCookie = 761017209
-->                         }

This log helps you to identity that the resource belongs to Network, specially to a vDS protgroup. Checking VM settings you can see that this is port ID used by the VM in the vDS Portgroup.

And That’s it. According to VMware’s official article, the VMware clone error “The resource is in use” can occur if the vSphere Distributed Switch portgroup has objects still attached to it. In addition, it mentioned that when an ESXi host has no running virtual machines and is on Maintenance Mode, you may cannot remove an ESXi host from the vDS.

vDS portgroup

Now you know that the resource is in use VMware distributed switch, the next thing you need to do is to troubleshoot vCenter logs in the clone why is this resource being use and canceling the clone. For example:

…”
error vpxd[fusion_builder_container hundred_percent="yes" overflow="visible"][fusion_builder_row][fusion_builder_column type="1_1" background_position="left top" background_color="" border_size="" border_color="" border_style="solid" spacing="yes" background_image="" background_repeat="no-repeat" padding="" margin_top="0px" margin_bottom="0px" class="" id="" animation_type="" animation_speed="0.3" animation_direction="left" hide_on_mobile="no" center_content="no" min_height="none"][21016] [Originator@6876 sub=coreanchor opID=E41217AA-0000011D-95-20] [Vds::Anchor::ProcessVmConfigSpec] Failed in reserving a port (vim.fault.ResourceInUse). Rolling back the previously reserved ports
info vpxd[11924] [Originator@6876 sub=vpxLro opID=69a43162] [VpxLRO] -- BEGIN task-internal-46214 -- ServiceInstance -- vim.ServiceInstance.GetContent -- 520d2706-dc38-8115-39cc-ba1f1714beb9
warning vpxd[27200] [Originator@6876 sub=VmprovUtil opID=E41217AA-0000011D-95-20-cc] [VpxdVmprovUtil::PatchConfig] Not persisting the serial port network backings. If you have VMs with network backings for serial ports, please set config option: vpxd.SerialPort.PersistNetworkBacking.
info vpxd[19668] [Originator@6876 sub=vpxLro opID=5928a086] [VpxLRO] -- BEGIN task-internal-46323 -- host-26437 -- vim.HostSystem.acquireCimServicesTicket -- 52fc85cd-5654-2c23-f50f-029957048d9b(5295d922-2f27-65b1-11f5-d957ffc89292)
warning vpxd[26412] [Originator@6876 sub=VpxProfiler opID=E41217AA-0000011D-95-20-TaskLoop-365a3afd] TaskLoop [TotalTime] took 20167 ms
info vpxd[21016] [Originator@6876 sub=VmProv opID=E41217AA-0000011D-95-20] [WorkflowXAction] Done undo action vpx.vmprov.CreateSnapshot with output:
--> false
error vpxd[21016] [Originator@6876 sub=vpxLro opID=E41217AA-0000011D-95-20] [VpxLRO] Unexpected Exception: vim.fault.ResourceInUse “…

It seems that the issue is when cloning the VM and removing the vDS port(source and destination). The resource ‘400’ is the vDS port on the VM source subnet. The cause is that the cloning is trying to create in the destination a vDS with the Port ID 400 using the same subnet that is already been use in the vDS Portgroup, so the clone fails.

How to resolve the VMware clone error “The resource is in use”

Now you know what caused the error the resource is in use VMware clone, the resolution is relatively simple. You just need to remove the interface (or change the network to vSwitch network) of the clone. After that, you can recreate the Interface, or just back to the original vDS network that you need.

1. Access and log in vSphere web client, right-click on the target VM and select Edit Settings…

Edit Settings

2. On the Virtual Hardware tab, to remove a network interface, select the network adapter and click the remove icon × next to it. Click OK to confirm.

Remove network interface

Clone ESXi VMs using backup and restore tool

If you use the free VMware ESXi, your options may have been limited by not having vCenter Server and not supporting vStorage APIs. In this regard, you can try a backup and restore tool that supports the free ESXi to perform VMware clone.

Most backup software offers the feature to clone multiple VMs at once at an affordable price, which can save the time and cost. However, many of them do not support the free ESXi.

Here I introduce you to a VMware backup software AOMEI Cyber Backup, it supports both paid and free versions of VMware ESXi, and enables you to backup multiple VMs in simple steps. In summary, it offers you the following benefits.

Agentless Backup: create complete and independent image-level backup for VMware ESXi and Hyper-V VMs.
 Support Free ESXi: support both paid and free versions of VMware ESXi.
Batch VM Backup: batch backup large numbers of VMs managed by vCenter Server or standalone ESXi hosts.
Multiple Storage Destinations: backup to local drive, or network destinations like Windows share or NAS.
Automated Execution: schedule to automate backups daily, weekly, and monthly with email notifications.
Restore Entire VM: restore instant available VMs from any selected restore points to original or new location.
Role Assignment: allows one administrator to create sub-accounts with limited privileges.

AOMEI Cyber Backup supports VMware ESXi 6.0 and later versions. Next, I will show you how to backup and restore VMware ESXi VMs with AOMEI Cyber Backup. You can click the following button to download.

Download Free TrialVMware ESXi & Hyper-V
Secure Download

*You can choose to install this VM backup software on either Windows or Linux system.

Steps to backup and restore VMware ESXi VMs

1. Bind Devices: Access to AOMEI Cyber Backup web client, navigate to Source Device > VMware > + Add VMware Device to add vCenter or Standalone ESXi host. And then click > Bind Device.

Add VMware ESXi host

2. Create Backup Task: Navigate to Backup Task > + Create New Task, and then set Task Name, Backup Type, Device, TargetSchedule, and Cleanup as need.

  • Device: cover multiple VMs on the host within one backup task.
  • Target: select to back up to a local path, or to a network path.
  • Schedule (optional): choose to perform full, differential or incremental backup, and automate execution according to the frequency you specified.
  • Cleanup (optional): automatically delete the old backup copies that exceed the retention period you specified.

Backup schedule type

3. Run Backup: Click Start Backup and select Add the schedule and start backup now, or Add the schedule only.

Start Backup

Created backup tasks will be listed and monitored separately for restoring, progress checking and schedule changing.

4. Restore VM: Click > Restore on the backup task to open a wizard, and click Select Content to specify a restore point.

restore

5. Select Restore to original location or Restore to new location, and then click Start Restore.

By selecting the latter one, you can create a new VM in another datastore/host directly from the backup.

Restore to new location

Summary

VMware clone is convenient to create exact copies of your original virtual machine, however, sometimes you may get the error: the resource is in use VMware clone. This is because the cloning is trying to create in the destination a vDS with the Port using the same subnet that is already been use in the vDS Portgroup.

To resolve this VMware clone error the resource is in use, you just need to remove the VMware network adapter before cloning, or change the network to vSwitch network. You can add it backup after clone.

Crystal
Crystal · Editor
Crystal is an editor from AOMEI Technology. She mainly writes articles about virtual machine. She is a positive young lady likes to share articles with peolpe. Off work she loves travelling and cooking which is wonderful for life.