WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / ESXi / How to manually clean up a Distributed Virtual Switch (VDS) on an ESXi host?

How to manually clean up a Distributed Virtual Switch (VDS) on an ESXi host?

08.18.2022 by William Lam // 7 Comments

If an ESXi host was connected to a Distributed Virtual Switch (DVS) and you were not able to properly remove it from the vCenter inventory, which cleans up the VDS as part of the removal, then you will be left with a stale VDS configuration.


Of course, the ideal workflow is to clean this up within vCenter Server but if you some how lost access or the vCenter Server was deleted and you might be wondering how to manually clean this up?

Step 0 - Ensure that no VMs or VMKernel interfaces are using the DVS and Distributed Portgroups (DVPG) resources. Re-create the vSphere Standard Switch (VSS) and the respective portgroups and reconfigure your VMs and VMKernel interfaces before continuing. If you need assistance, please search online as there are many resources that outlines these steps and this will no be covered in this article.

Note: In theory, after Step 0 you could technically jump to Step 5 and just delete the VDS database but I prefer to clean up resources prior to that step but this also works if you are in a pinch.

Step 1 - Run the following command to list current VDS and associated uplink ports that are configured. In the example below, I have a VDS named foo with a single uplink vmnic1 which is consuming port 9. Your environment may be configured differently, so please make a note of these values as you will need it in the next steps.

esxcfg-vswitch -l

Step 2 - Remove the uplink from VDS by running the following command and specifying the uplink, uplink port and VDS name.

esxcfg-vswitch --del-dvp-uplink=vmnic1 --dvp=9 foo

Step 3 - Delete VDS by runnning the following command and specifying VDS name.

net-dvs -d foo

Once the VDS has been deleted, what I have found (at least with the cswitch in ESXi 7.0 Update 3), is that a tangling DvsPortset-N is left when you run the following command:

esxcfg-vswitch -l

Step 4 - Depending on the number of DvsPortset-N, you will need to run this additional command and replace the N with value observed from previous step.

vsish -e set /net/portsets/DvsPortset-0/destroy destroy

Note: If this command returns busy, it means there were still workloads or VMkernel interfaces using VDS that was not cleaned up as part of Step 0. You can ignore and move to next step

Step 5 - Next, we delete the VDS database file which is needed or else VDS will be re-created upon the next reboot.

rm -f /etc/vmware/dvsdata.db

Step 6 - Finally, reboot the ESXi host and the VDS should now be completely removed.

More from my site

  • Migrating ESXi to a Distributed Virtual Switch with a single NIC running vCenter Server
  • Retrieving statistics for a Distributed Virtual Port using the vSphere API & PowerCLI
  • Automatically Remediating SvMotion / VDS Issue Using vCenter Alarms
  • Identifying & Fixing Virtual Machines Affected By SvMotion / VDS Issue
  • Quick Tip - Retrieving vSphere Distributed Switch (VDS) DVPort ID & Stats using PowerCLI

Categories // ESXi Tags // distributed virtual switch, dvs, net-dvs, vds

Comments

  1. *protectedMichael says

    01/09/2023 at 8:23 pm

    Thanks for the great post. It was really helpful.

    Reply
    • *protectedAndy Machado says

      09/11/2024 at 8:41 am

      As of VCenter 8.0u3, it appears that once you've removed all uplinks to an unused DSwitch, Vcenter cleans up all associated unused Dswitches and port groups.

      Essentially, we only needed to remove the uplinks from the DSwitch and use the VCenter GUI to add the removed uplinks to the new VCenter DSwitch.

      Reply
  2. *protectedHISSOUROU M says

    05/05/2023 at 5:28 pm

    Thank you !

    Reply
  3. *protectedEnrique L. says

    06/02/2023 at 10:18 am

    Thank you.
    Very helpful info.
    Got me out of a jam!

    Reply
  4. *protectedMark Edwards says

    02/07/2024 at 5:32 pm

    Hey William. I hit this issue today on my homelab, running ESXi 8.0.2 however the path to /net/portsets doesn't exist on this build.

    Running find . -type d | grep -i "portsets" from root returns no hits, so where does it store this data on this version?

    I worked around it by removing dvsdata.db and rebooting, this cleared it from the UI, but not sure if its left anything behind on the host! Just thought i'd pass this on for reference. Keep up the great work 🙂

    Reply
  5. *protectedTC says

    12/17/2024 at 4:38 pm

    Is there a way to remove an unused uplink from a vDS if NSX 4.1 is used?

    Reply
  6. *protectedNelson says

    02/27/2025 at 3:37 pm

    This is what ultimately worked for me using PowerCLI and after removing uplinks and disconnecting the host from vCenter:

    Remove-VDSwitchVMHost -VDSwitch vdswitchname -VMHost vmhostname

    Reply

Thanks for the comment!Cancel reply

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

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...