Error: “The virtual machine or snapshot is already in use” while performing snapshot deletion task
search cancel

Error: “The virtual machine or snapshot is already in use” while performing snapshot deletion task

book

Article ID: 413149

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • When attempting to delete a snapshot from a virtual machine, the following error message is displayed and the task fails: 
    Task name: Remove snapshot
    Status  An error occurred while deleting a snapshot: 
    One of the disks in this virtual machine is already in use by a virtual machine or by a snapshot.
  • In vmfs/vomumes/datastore/vm-name/vmware.log, displayed messages are similar to the following, indicating that the same VMDK file is already opened by another snapshot: 
    SNAPSHOT: SnapshotDiskTreeAddFromSnapshot: Trying to add snapshot ###-Snapshot2.vmsn to disk /vmfs/volumes/.../###.vmdk which already has snapshot ###-Snapshot1.vmsn.
    SNAPSHOT: SnapshotGenerateDeleteDisks Failed to fetch disk tree: One of the disks in this virtual machine is already in use by a virtual machine or by a snapshot (21)
    SNAPSHOT: SnapshotDeleteNode failed: One of the disks in this virtual machine is already in use by a virtual machine or by a snapshot (21)
  • Snapshot creation succeeds, but deletion fails
  • OVF export tasks may also fail
  • Powering on virtual machine mail fail with error 
     "Operation failed" Status: Failed to enumerate all disks. One of the disks in this virtual machine is already in use by a virtual machine or by a snapshot

Environment

  • VMware vSphere ESXi 8.X
  • VMware vSphere ESXi 7.X

Cause

  • This issue indicates corruption in the snapshot disk chain.
    In the vmsd file, vmname.vmsd located in the directory of vmfs/volumes/datastore/vm-name, there will be similar entries to the following:
    snapshot0.uid = "1"
    snapshot0.filename = "Direct-###-Snapshot1.vmsn"
    snapshot0.disk0.fileName = "Direct-###01.vmdk"
    snapshot0.disk0.node = "scsi0:0"
    
    snapshot1.parent = "1"
    snapshot1.uid = "2"
    snapshot1.filename = "Direct-###-Snapshot2.vmsn"
    snapshot1.disk0.fileName = "Direct-###01.vmdk"
    snapshot1.disk0.node = "scsi0:0"
  • Although snapshot0 and snapshot1 have a parent–child relationship, both reference the same base VMDK file, creating a logical inconsistency in the snapshot chain.
  • As a result, the disk is detected as "in use" during deletion, and the snapshot removal process fails.

Resolution

  1. Important: Before proceeding, take a full backup of the virtual machine.
  2. Specify the VMDK file containing the latest data, and perform cloning using vmkfstools (Cloning and converting virtual machine disks with vmkfstools).
  3. Power off the affected virtual machine

  4. Connect to the ESXi host where the VM is registered via SSH.

  5. Navigate to the directory containing the VM configuration files.

    cd /vmfs/volumes/datastore_name/virtual_machine_name/
  6. Rename or remove the vmsd file:
    mv virtual_machine_name.vmsd virtual_machine_name.vmsd.bak
  7. Power on the virtual machine.

  8. In the vSphere Client, verify if an alarm indicates that disk consolidation is required.

  9. Select VM > Actions > Snapshots > Consolidate to consolidate the disks.

  10. Once consolidation is successful, try creating and deleting snapshots again.

Additional Information