Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Virtualization / VMWare / VMWare: Virtual Machine Disks Consolidation is Needed

September 16, 2022 PowerShellVMWare

VMWare: Virtual Machine Disks Consolidation is Needed

The warning ‘Virtual Machine disks consolidation is needed’ in the Summary tab of a virtual machine in the VMware vSphere Client console means that when deleting snapshots (using the Delete or Delete All options), there were files left on the disk that could not be merged (committed) with the main virtual disk file (vmdk). As a result, you cannot backup such a virtual machine, and its performance is degraded.

vmware virtual machine disks consolidation is needed

Virtual machine Consolidation Needed status.
Virtual Machine disks consolidation is needed.

Contents:
  • How to Consolidate Disks in VMware?
  • Disk Consolidation File Lock Errors
  • Consolidate VM Snapshots with PowerCLI

The most typical causes of the ‘Virtual Machine disks consolidation is needed’ error are:

  • Poor storage performance, due to which snapshots cannot be deleted/consolidated due to a timeout or a large size of a snapshot;
  • There is not enough free space on the VMFS datastore to perform consolidation, there must be at least 1 GB free (see how to increase VMFS datastore capacity in VMware ESXi);
  • Snapshot files are locked by vSphere or a third-party app (typically by a backup app, such as HP DataPtotector, Veeam, or Netapp VSC). Make sure there are no running VM backup processes;
    The problem can be caused by adding VM disks (hot-add) to the backup appliance when performing backups. In some cases, you need to manually disconnect the virtual disks of problematic VMs in the backup appliance settings (this happens in Veeam Backup Proxy, Symantec NetBackup, and CommVault Media Agent).
  • A VM has more than 32 snapshots (the maximum number recommended by VMware);
  • The background process of large snapshots consolidation has been launched;
  • Connection problems (possibly temporary) between the vCenter server and the ESXi host.

How to Consolidate Disks in VMware?

To fix the error ‘Virtual machine Consolidation Needed’, right-click on the virtual machine and select VM -> Actions -> Snapshots -> Consolidate.

consolidate snapshots in the vcenter console

A window with the following request appears:

Confirm Consolidate
This operation consolidates all redundant redo logs on your virtual machine. Are you sure you want to continue?

This operation consolidates all redundant redo logs on your virtual machine

Confirm that you want to delete the redundant logs. Then vCenter will consolidate disks and clear the logs. The consolidation process can take a long time depending on the size of the VM, the number of snapshots, and the current host/datastore load. During consolidation, VM performance may degrade. Wait for the “Consolidate virtual machine disk files” task to complete.

consolidating vmdisks vsphere

When consolidation is performed, data from the delta disks are merged with the main disk and unnecessary files on the storage are removed. After that, the warning of the VM consolidation will disappear.

Disk Consolidation File Lock Errors

In some cases, when performing a consolidation you may see this error in the vSphere console:

Unable to access file since it is locked. An error occurred while consolidating disks: Failed to lock the file. Consolidation failed for disk node ‘scsi0:0’: Failed to lock the file.

or

Consolidate virtual machine disk files - Unable to access file since it is locked.

vm consolidate: Unable to access file since it is locked. An error occurred while consolidating disks: Failed to lock the file. Consolidation failed for disk node

In this case, VMware recommends restarting Management agents on the ESXi server. To do it, connect to the ESXi host via SSH and run this command:

services.sh restart

restart Management agents on esxi: services.sh restart

If this doesn’t help, check who has locked the virtual machine files.

  1. Go to the VM directory on the VMFS datastore: # cd /vmfs/volumes/xxxxxx-xxxxxx-xxxx-xxxxxxx/WINSRV1
  2. List locked VM files and which ESXi hosts hold these files: # for i in `ls`; do vmfsfilelockinfo -p $i ;done|grep 'is locked in\|Host owning the lock\|Total time taken' | sed 's|Host owning the lock on file is||g'|sed 's|Total time|---|g' | awk '{print $1}' |uniq
  3. The previous command will return something like this:
    ---
    "WINSRV1-bf11abd3.vswp"
    Esxi01,
    ---
    "WINSRV1-flat.vmdk"
    Esxi02,
    Esxi01
  4. In this example, you can see that the WINSRV1-flat.vmdk file is locked by two hosts. To release the file lock from the second host, connect to Esxi02 via SSH and run the commands:
    # /etc/init.d/hostd restart
    # /etc/init.d/vpxa restart
  5. Run the consolidation from the vSphere Client interface.

Also, you can try to unlock the VM files as follows:

  1. Shutdown the VM if it is possible;
  2. Create a new snapshot;
  3. Remove all the VM snapshots using the ‘Delete All’ option;
  4. Move running VM to another ESXi using vMotion;
  5. Try to consolidate snapshots as described above.

vmware vm: delete all snapshots

If the Consolidate option is inactive in the VM menu (grayed out button), and there are still a large number of delta snapshot files in the datastore, the integrity of the snapshot chain is most likely broken (error: Unable to enumerate all disks).

consolidate option grayed out (inactive) in vmware virtual machine

Try to manually remove the VM from the list (Remove from Inventory) and re-register the VMX file of the virtual machine from the Datastore Browser. If this doesn’t help, check and fix the errors in the snapshot chain as described here: The parent virtual disk has been modified since the child was created (https://kb.vmware.com/s/article/1007969).

Consolidate VM Snapshots with PowerCLI

You can find all virtual machines that require consolidation using PowerCLI (this module allows you to manage VMware infrastructure). To do it, connect to your vCenter server or ESXi host:

Connect-VIServer mun_vsphere.woshub.com

Get the list of all VMs with the status ‘Virtual machine disks consolidation is needed’:

Get-VM | Where-Object {$_.Extensiondata.Runtime.ConsolidationNeeded}

Now you can consolidate the disks of all virtual machines in the list:

Get-VM | Where-Object {$_.Extensiondata.Runtime.ConsolidationNeeded} | foreach {$_.ExtensionData.ConsolidateVMDisks_Task()}

ConsolidateVMDisks using vmware powercli

You can automatically consolidate VM snapshots older than 30 days using the following PowerShell script:

$VMName = Get-VM | Get-Snapshot |
Where {$_.Created -lt (Get-Date).AddDays(-30)} | select VM |
ForEach-Object {
$VMName.ExtensionData.ConsolidateVMDisks()
}

0 comment
5
Facebook Twitter Google + Pinterest
previous post
How to Fix the ‘Too Many Open Files’ Error in Linux
next post
How to Enable and Configure SSH Server on Windows with OpenSSH

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

Reset Root Password in VMware ESXi

October 12, 2023

How to Query and Change Teams User Presence...

October 8, 2023

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Configuring Port Forwarding in Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • How to Delete Old User Profiles in Windows
  • Get-ADUser: Find Active Directory User Info with PowerShell
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top