Delete vm snapshot from cli when Snapshot Manager fails to detect snapshots of VMs
search cancel

Delete vm snapshot from cli when Snapshot Manager fails to detect snapshots of VMs

book

Article ID: 331556

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This article provides steps to commit snapshots using Command Line Interface (CLI).


Symptoms:

Snapshots of virtual machines running on snapshot disks are not detected by the Snapshot Manager.


Environment

VMware ESXi 4.x,

VMware ESXi 5.x,

VMware ESXi 6.x,

VMware ESXi 7.x,

VMware ESXi 8.x

Resolution

To resolve this issue, consolidate snapshots on the ESXi host.

To consolidate snapshots on the ESXi host:
  1. Log in to the ESXi console through iLO/DRAC or ssh as a root user.
  2. Navigate to the virtual machine directory containing the .vmdk files. (/vmfs/volumes/<Data store>/<VM folder> )
  3. Run this command to list files in the directory:

    ls -ltrh *.vmdk
     
  4. Locate snapshot files similar to VM_NAME-00000#.vmdk or VM_NAME-00000#-delta.vmdk.

    Note: The delta files should have the current timestamp
     
  5. Run this command to get a list of virtual machines and the VMID for each virtual machine:

    vim-cmd vmsvc/getallvms

    Note the VMID of the virtual machine for which the snapshot is not detected.
     
  6. Run this command to verify if the snapshot exists:

    vim-cmd vmsvc/snapshot.get VMID
     
  7. Run this command to remove all snapshots:

    vim-cmd vmsvc/snapshot.removeall VMID
 
If the snapshot.removeall command fails with the error Cannot find VMID, run these commands:

 
  1. Run this command to create a new snapshot:

    vim-cmd vmsvc/snapshot.create VMID snapshotName description includeMemory quiesced

    Where includeMemory and quiesced variables are Boolean values. Set the value to 1 to enable or 0 to disable the snapshot option.

    For example:

    # vim-cmd vmsvc/snapshot.create 10 my_snapshot snapshot_test 0 0
     
  2. Run this command to remove all snapshots:

    vim-cmd vmsvc/snapshot.removeall VMID


Additional Information

To verify if the virtual machine is running on snapshot disks:

  1. Right-click the virtual machine and click Edit Settings.
  2. Select the Virtual Disk and check the Disk File. If it is labeled as VM-000001.vmdk, the virtual machine is running on snapshot disks.

Committing snapshots when there are no snapshot entries in the Snapshot Manager
Investigating virtual machine file locks on ESXi

Cloning and converting virtual machine disks with vmkfstools
Troubleshooting issues when creating or committing snapshots in VMware ESXi/ESX