VMware

Delete VMware Distributed Virtual Switch The Resource Is In Use

In my home lab, ran into the issue when trying to Delete VMware Distributed Virtual Switch The Resource Is In Use. Using command line tools, you can successfully troubleshoot and resolve many DVS issues. Let's see how

Recently, in working with the home lab environment, moving hosts around, playing around with various networking, etc, I ran into an issue with a distributed virtual switch (DVS) I had configured. The problem started with a host that was forcibly removed from a test cluster. The distributed virtual switch existed on the host, however, was not synchronized with vCenter Server. This is address in the this highlighted VMware KB article. The normal synchronization fix did not work, so I was left with a distributed switch in a bad state on the host even though it was functioning in carrying traffic. In vCenter Server it did see the host had the switch configured but again was in an “out of sync” state. I decided to simply delete the distributed virtual switch from the host since all virtual machines had been evacuated from it. However, I ran into the error with the operation Delete VMware Distributed Virtual Switch The Resource Is In Use.

Delete VMware Distributed Virtual Switch The Resource Is In Use

As mentioned, below is the error that I saw in the vSphere web client when attempting to remove the distributed virtual switch from the ESXi host.

Delete-VMware-distributed-virtual-wwitch-the-resource-is-in-use
Delete VMware distributed virtual wwitch the resource is in use

Command line commands to help troubleshoot Distributed Virtual Switches

Since I was in a state of the GUI not helping me much with the distributed virtual switch being out of sync, the command line becomes your friend.ย  I couldn’t really see what was causing the issue with deleting the virtual switch as all virtual machines had been evacuated.ย  There were a couple of commands that allowed me to key in on the underlying issue and resolve it.

The commandย esxcli networkย vswitchย dvs vmware list lists the distributed virtual switches, ports, vmkernel ports, in use status, etc.ย  Note in the screenshot below that we see a distributed virtual switch port with anย In use: true.

esxcli networkย vswitchย dvs vmware list
Listing-VMware-distributed-virtual-switches-from-command-line
Listing VMware distributed virtual switches from command line

The above output shows us that there is anย In use resource on the distributed virtual switch.ย  Theย client shows to beย vmk1.ย  So we have a vmkernel port that is keeping us from deleting the distributed virtual switch from the host.

How can we delete the distributed virtual switch vmkernel port from the command line?

esxcli network ip interface remove --interface-name=vmk1

Using this command I was able to remove the vmkernel port.ย  In rerunning the command to list the DVS configuration in the environment, the port was no longer in use.ย  Could I now successfully delete the distributed virtual switch from the host?ย  Let’s see.ย  All good now!

Successfully-deleted-the-distributed-virtual-switch-from-an-ESXi-host
Successfully deleted the distributed virtual switch from an ESXi host

In this case, knowing how to interact with distributed virtual switches from the commandline is extremely helpful, especially in cases where the relationship or communication is broken with vCenter Server.ย  A great resource in configuring VMware distributed virtual switches from the command line is this KB article:ย ย https://kb.vmware.com/s/article/1008127

Concluding Thoughts

VMware distributed virtual switches require more care when it comes to vCenter interaction with hosts than do Standard vSwitches.ย  Since everything is maintained at the vCenter level from a management perspective, the host must be in sync with the vCenter Server to properly administrate the ESXi host.ย  If not, you will encounter issues as I did when trying to Delete VMware Distributed Virtual Switch The Resource Is In Use.ย  However, by using the builtin command line utilities and commands, we can successfully troubleshoot many of the issues you can encounter with distributed virtual switches and successfully resolve issues that simply can’t be resolved using the GUI.

Subscribe to VirtualizationHowto via Email ๐Ÿ””

Enter your email address to subscribe to this blog and receive notifications of new posts by email.



Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com, and a 7-time VMware vExpert, with over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, He has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family. Also, he goes through the effort of testing and troubleshooting issues, so you don't have to.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.