The most typical causes for VMs to show ‘Virtual Machine disks consolidation is needed’ Alert:
VMware vSphere ESXi
Overview
Typically, the snapshot file is in use by the virtual machine until the snapshot is consolidated/deleted. When a snapshot is deleted, any additional files in the hierarchy that are not identified by the Snapshot Manager are included in the commit process.
Sometimes, if the VMs show consolidation needed and no snapshots are present under the snapshot manager, creating a new snapshot and deleting it clears the entire hierarchy. This means that all snapshot files on the virtual machine are committed, then deleted.
A small amount of free space is required to create the new snapshots. If the virtual machine needs to remain running, more space must be allowed as the new snapshot grows (accepting new changes to the virtual disks) as the older snapshots commit.
Checking if virtual machine consolidation is required with the Web Client
To check if virtual machine consolidation is required:
Select a vCenter Server host or a cluster and click the Virtual Machines tab.
Right-click any of the virtual machine and click Snapshot Manager/Manage snapshots, it would show "Needs Consolidation/Delete Snapshots".
Note: A Configuration Issue warning is also displayed in the Summary tab of the virtual machine indicating that virtual machine disk consolidation is needed.Alternatively, edit the settings of the virtual machine and see if any of the virtual disks are using a -00000X.vmdk file. If no disks are using -00000X.vmdk, this virtual machine is not using any of these files. Although unlikely, it is possible that another virtual machine is storing its snapshots in this directory. Check the other virtual machines. If none of them refer to these files, they can be safely erased.
Checking if virtual machine is running on a snapshot, via Command Line
Open the virtual machine configuration file (.vmx). Entries in the configuration file (.vmx) file related to virtual disks start with scsix:x. Perform this while connected to an ESXi host through DCUI or SSH. This command shows the information of the virtual disks of a virtual machine:
grep file /vmfs/volumes/datastoreName/VMname/VMname.vmx
Example:
grep vmdk "/vmfs/volumes/lun1/TestVM/TestVM.vmx"
scsi0:0.fileName = "TestVM-000001.vmdk"
Use the vim-cmd commands which is mentioned under the "Commit snapshots from the ESXi command line" section.
Commit snapshots using the vSphere Web Client and HTML5 Client 6.x/7.x/8.x
To commit all snapshots by using the vSphere Client:
Commit snapshots using the vSphere Client 6.0
To commit all snapshots by using the vSphere Client:
Note: If unsuccessful in attempting to consolidate using the Take a Snapshot then Delete all Snapshots technique, attempt the technique again, but this time select the Quiesce guest file system checkbox to enable quiesced snapshots when performing a new snapshot.
Commit snapshots from the ESXi command line
To commit all snapshot from the command line on ESXi:
vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
1 vm1 [datastore1] vm1/vm1.vmx windows7Server64Guest vmx-08
3 testvm [iscsi1] testvm/testvm.vmx winNetDatacenterGuest vmx-08
Vmid
for the specific virtual machine.vim-cmd vmsvc/snapshot.get [Vmid]
Get Snapshot:
|-ROOT
--Snapshot Name : SnapshotTest
--Snapshot Desciption :
--Snapshot Created On : 11/27/2019 13:49:55
--Snapshot State : powered on
vim-cmd vmsvc/snapshot.create [VmId] [snapshotName] [snapshotDescription] [includeMemory] [quiesced]
vim-cmd vmsvc/snapshot.create 3 SnapshotTest AsnapshotDescription 0 0
.vmsd
may interfere with the creation or removal of the snapshots if a memory snapshot was left behind. For more information, see Overview of virtual machine snapshots in vSphere.vim-cmd vmsvc/snapshot.removeall [Vmid]
file *
command to see if any files are in use. If any of the files return the error message can't read `filename' (Device or resource busy,
they are locked by the VMkernel. The commit process is actively being performed on those files.-00000X.vmdk
or -00000X-delta.vmdk
files left unless they were not part of the snapshot tree. These files can be deleted. To confirm that the commit succeeded, view the .vmx
file, and verify that virtual disks are now pointing to a base disk (-flat.vmdk
). .vmx
contains a disk that is still pointing to a snapshot file, the commit process failed. If the attempt was made with the virtual machine running, plan a maintenance window and try again with the virtual machine powered off. If that does not work, the virtual disk must be cloned using vmkfstools -i
. The source file name is the current active -00000X.vmdk
as identified in the .vmx
file. When the clone is complete, point the virtual machine to use the newly cloned disk. The original base disk and snapshot tree can be deleted.Note: Cloning using the vSphere Client, vSphere Web Client or HTML5 Client requires vCenter Server and all applicable licenses and does not allow individual virtual disks to be selected when connected to the virtual machine. Relative to using the vmkfstools -i
command to perform the same operation on a single virtual disk, consolidating snapshots using vSphere Clients clones all disks and may require more disk space.