Symptoms / Introduction:
Attempts to create a snapshot of a virtual machine fail with an error message resembling the following:
"The attempted operation cannot be performed in the current state (powered off)"
"The attempted operation cannot be performed in the current state (powered on)"
Additionally, when creating a snapshot from the ESXi command line using vmware-cmd The following error is encountered:
VMware vSphere ESXi 6.0
VMware vSphere ESXi 6.7
VMware vSphere ESXi 6.5
This issue can occur when the .vmsd metadata file contains an invalid or stale snapshot reference. Specifically, if the snapshot.current entry points to a snapshot UID that does not exist, the virtual machine may be unable to process new snapshot requests correctly. This can lead to operational failures, including unexpected VM power-off events during snapshot creation.
Example:
In the following .vmsd file, the snapshot.current value is set to 38, but no snapshot with UID 38 exists:
In this scenario, snapshot.current = "38" is referencing a non-existent snapshot UID, resulting in a snapshot creation failure.
To resolve this issue, follow one of the appropriate options based on your virtual machine’s snapshot status:
If the virtual machine does not currently have any snapshots:
Delete the .vmsd file from the virtual machine's directory.
The file will be automatically regenerated the next time a snapshot is created or when the virtual machine is powered on.
If the virtual machine has existing snapshots:
Manually edit the .vmsd file to update the snapshot.current value to match a valid existing snapshot UID listed in the file.
Once the virtual machine is running:
Commit (delete) all existing snapshots.
Power off the virtual machine.
Delete the .vmsd file.
The .vmsd file will be recreated during the next power-on event or snapshot creation.
Ensure that any manual modifications to .vmsd are performed carefully and only after taking appropriate backups.
If unsure, consider cloning the VM or copying its configuration files before making changes.