WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • 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 // 3 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
  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

Thanks for the comment!Cancel reply

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

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC) across Private, Hybrid and Public Cloud

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • vSphere Code Capture is your ChatGPT for vSphere Automation 11/30/2023
  • ESXi 8.0 Update 2 not detecting Apple NVMe on Apple Mac Mini 2018 11/28/2023
  • Is there a vSphere REST API for ... 11/21/2023
  • Custom vSAN HCL JSON for VMware Cloud Foundation (VCF) 5.1 and vSAN ESA using Nested ESXi 11/20/2023
  • Heads Up - Performance Impact with VMware Workstation on Windows 11 with Intel Hybrid CPUs 11/19/2023

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 © 2023

 

Loading Comments...