Cannot remove datastore because "local swap is enabled on it". Correct the problem and retry the operation.
search cancel

Cannot remove datastore because "local swap is enabled on it". Correct the problem and retry the operation.

book

Article ID: 391606

calendar_today

Updated On: 04-06-2025

Products

VMware vSphere ESXi

Issue/Introduction

Symptoms : 

  • Unable to delete the datastore.

  • Remove datastore fails with error : Cannot remove datastore local swap is enabled on it". Correct the problem and retry the operation.

Validation Step:

  • In the var/log/vmware/vpxd/vpxd.log file, similar entries are seen:

    -->          message = "Cannot remove datastore '<Datastore name>' because local swap is enabled on it. Correct the problem and retry the operation."

Environment

VMware vSphere ESXi 6.x
VMware vSphere ESXi 7.x
VMware vSphere ESXi 8.x

Cause

Local swap was enabled on the affected datastore "<Datastore name>" preventing datastore deletion.

Cause validation:

  • In the var/log/vmware/vpxd/vpxd.log file, similar entries are seen:

    YYYY-MM-DDTHH:MM.SSSZ error vpxd[2226909] [Originator@6876 sub=Default opID=m5uzjs0y-2285623-auto-1czlm-h5:70132331-3e] [VpxLRO] -- ERROR task-53704 -- 526443f5-5370-e5c5-6cf1-0661ec62694c(52148094-c8cf-d620-cd6a-d83864fd96a3) -- data
    storeSystem-37137 -- vim.host.DatastoreSystem.removeDatastore: :vim.fault.ResourceInUse
    --> Result:
    --> (vim.fault.ResourceInUse) {
    -->    faultCause = (vmodl.MethodFault) null,
    -->    faultMessage = (vmodl.LocalizableMessage) [
    -->       (vmodl.LocalizableMessage) {
    -->          key = "com.vmware.vim.datastore.error.removeDatastoreFailed",
    -->          arg = (vmodl.KeyAnyValue) [
    -->             (vmodl.KeyAnyValue) {
    -->                key = "name",
    -->                value = "<Datastore name>"
    -->             },
    -->             (vmodl.KeyAnyValue) {
    -->                key = "reason",
    -->                value = "localSwapEnabled"
    -->             }
    -->          ],
    -->          message = "Cannot remove datastore '<Datastore name>' because local swap is enabled on it. Correct the problem and retry the operation."
    -->       }
    -->    ],
    -->    type = ,
    -->    name = "<Datastore name>"
    -->    msg = "Received SOAP response fault from [<, <UNIX '/var/run/envoy-hgw/hgw-pipe'>>, /hgw/host-37137/vpxa>]: removeDatastore
    --> Received SOAP response fault from [<, <TCP 'xxx.x.x.x : xxxx'>>, /sdk>]: removeDatastore
    --> The resource '<Datastore name>' is in use."
    --> }
    --> Args:
    -->
    --> Arg datastore:

Resolution

  • Navigate to Cluster > configure > configuration > General. Change the swap file location from 'Virtual machine directory' to "Datastore Specified by Host".
  • Navigate to  host > configure > Virtual Machines > Swap File Location. Modify the Default swap file location to other datastore.
  • Delete the datastore.
  • Navigate to Cluster > configure > configuration > General. Change the swap file location back to 'Virtual machine directory'