When a snapshot VMDK files or logs have not been deleted correctly, a warning error "VMWare: virtual machine disks consolidation is needed" will be triggered.
Here at Ibmi Media, as part of our Server Support Services, we regularly help our Customers to fix VMWare related errors.
In this context, we shall look into the main causes of this error and how to get rid of it.
Various factors can cause this VMWare error as outlined below;
i. Due to poor storage performance, the Snapshots cannot be deleted. This is due to a timeout or a Large size of the snapshot.
ii. When there is no enough space on the VMFS store to perform consolidation.
iii. When the vSphere or a third-party app has locked snapshot files. Ensure that no processes of a virtual machine backup are running.
iv. When there is a connection issue between the vCenter Server and the ESXi host.
To fix this error, start by right-clicking on the virtual machine and navigate through "VM >> Snapshots >> Consolidate".
This will display a windows which states that "This operation consolidates all redundant redo logs on your virtual machine. Are you sure you want to continue?" to confirm Consolidate where you have to choose either "yes" or "no".
In this case, you have to click on "Yes" to confirm that you want to delete the redundant logs. This action will enable the vCenter will consolidate disks and clear the logs. This might take a few minutes to be completed and might degrade the VM performance.
Finally, the VM consolidation warning error will go away.
In other cases, you might get an error in the vSphere console in the process of consolidation as shown below;
Unable to access file since it is locked
Unable to access file since it is locked.
An error occurred while consolidating disks: Failed to lock the file.
Consolidation failed for the disk node 'scsi0:0':
Failed to lock the file
If this is the case, VMWare recommends restarting Management agents on the ESXi server.
To achieve this, run the command below after connecting to the host via an SSH tool such as putty;
services.sh restart
Additionally, you can try to unlock the VM files by following the steps below;
1. Start by shutting down the VM.
2. Then create a new Snapshot.
3.With the option "‘Delete All", delete all the VM snapshots.
4. With vMotion, you can move the VM to another ESXi.
5. You can try to Consolidate the snapshots as advised above.
Also, you can use PowerCLI to find all the virtual machines which requires consolidation. To achieve this, make a connection to your vCenter server via the command below;
Connect-VIServer mun_vsphere.woshub.com
Now, get the list of all the VMs with the status 'Virtual machine disks consolidation is needed as shown below;
Get-VM | Where-Object {$_.Extensiondata.Runtime.ConsolidationNeeded}
Next, you have to consolidate the disk of all machines in the list by running the command below;
Get-VM | Where-Object {$_.Extensiondata.Runtime.ConsolidationNeeded} | foreach {$_.ExtensionData.ConsolidateVMDisks_Task()}
This guide will help you to fix the warning error experienced in the process of deleting a snapshot, the snapshot VMDK files or logs have not been deleted correctly.