Ошибка консолидации диска в vmware

Virtual machines in VMware vSphere have many advantages. They work reliably with high performance if the appropriate hardware is used and the right software configuration is applied. Sometimes the virtual machine consolidation needed status is displayed in the VMware vSphere Client, and a system administrator has to fix this error. This blog post explains why VMware virtual machine disks consolidation is needed and how this error can be fixed.

What Is VMware Disk Consolidation?

Virtual disk consolidation is the process of merging virtual disk files created after taking VM snapshots. You can initiate disk consolidation on demand to avoid performance degradation and other issues. When you take a snapshot, delta disks are created and changes are written to the appropriate delta disk (the latest delta disk by default, until one of the previous snapshots is selected to restore the virtual machine). As a result, redundant data is present in the virtual machine storage because each delta disk contains all changes made as compared to the previous delta disk state, and the parent disk remains unchanged.

When the chain of snapshots and related virtual disk files becomes large, performance degrades. When you perform VMware disk consolidation, data from delta disks is merged to a single disk, and no redundant data is left on the datastore where this VM’s files are located. Storage space is cleaned after you consolidate virtual machine disk files. Remember that VMware recommends using no more than 32 snapshots per VM.

Possible Reasons for the VMware Disk Consolidation Error

The VMware virtual machine disks consolidation is needed error message is displayed in the VM Summary tab in the VMware vSphere Client (screenshot below). One of the common reasons for this error message is incorrectly deleting a VM snapshot, which can leave VMDK files related to snapshots and log files on the datastore (for example, after you performed the Delete All or Delete operation for VM snapshots).

The virtual machine consolidation needed status is displayed in vSphere Client

The most common causes for the virtual machine consolidation needed status:

  • Not enough disk space on the VMFS datastore to consolidate VM snapshots and consolidate virtual disk files. If there is less than 1 GB of free space on the datastore, this error may occur.
  • Low performance of a storage system attached to an ESXi host on which a VM is running. If the snapshot size is large or times out, snapshot consolidation can fail.
  • Connection issues between an ESXi host and vCenter.
  • Snapshot files are locked by a third-party application, for example, a backup application. This may occur if a backup application did not finish a backup job and locked the snapshot (backup applications can create a temporary snapshot of a virtual machine when running a backup). Backup applications are unable to quiesce disk without using snapshot techniques to make a consistent backup of a running VM.

Basically, you should restore the consistency of VM disk files.

How to Fix the Error?

To fix the virtual machine consolidation needed status, right click the VM name in the VMware vSphere Client and in the menu that opens, click Snapshots > Consolidate.

VMware snapshot consolidate

A confirmation message is displayed:

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

Click Yes to confirm and consolidate virtual machine disk files.

Note: If there is a concern that some data can be lost during VMware disk consolidation, make a VMware VM backup, for example, copy all VM files to another folder on a datastore and then perform VMware disk consolidation.

Wait until the VMware disk consolidation is complete and the logs are cleared. You can see the task progress in the task panel at the bottom of the VMware vSphere Client interface. If the VM is running, VM performance can degrade during this operation. The time needed to finish this operation depends on the VM size, the number of snapshots, and VM load.

After the VMware disk consolidation task is finished, the warning that VMware virtual machine disks consolidation is needed should disappear.

Errors that May Occur

Sometimes, another error can occur during VMware disk consolidation and the following error message is displayed:

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’.

Locks can be also created when backup applications use the hot-add disk option for a backup when using snapshots. The VM file lock is intended to avoid concurrent writes to the file by multiple ESXi hosts.

Try to perform the following actions to fix this error.

  1. Restart management agents on the ESXi server on which the VM resides. Open ESXi shell or connect to the ESXi host via SSH and run the command as root:

services.sh restart

or

/etc/init.d/hostd restart

/etc/init.d/vpxa restart

You can also open the ESXi direct console, go to Troubleshooting Options, and select Restart Management Agents (press Enter to activate the needed option, then press F11 to confirm).

  1. Check the locked file with the command:

vmfsfilelockinfo -p /vmfs/volumes/vm_datastore/vm_name/vm_name.vmx

  1. Check the hostd log file if you need to identify the path on the datastore where the VM files are located.

cat /var/log/hostd.log |grep -i vm_name

  1. Go to the VM directory on the datastore when you know the VM files’ location:

cd /vmfs/volumes/datastore_name/vm_name

  1. Run the command to list ESXi hosts that are locking the VM 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

  1. Restart ESXi management agents, including hostd and vpxa as explained above, or run these commands on the ESXi host locking the VM files:

/etc/init.d/hostd restart

/etc/init.d/vpxa restart

Another method to unlock VM files

As an alternative, try these steps to fix an error occurred while consolidating disks: Failed to lock the file.

  1. Shut down the virtual machine.
  2. Take a new VM disk snapshot.
  3. Delete all existing VM snapshots. Right click the VM name in vSphere Client, select Snapshots, and click Delete All Snapshots.

VMware delete snapshot

  1. Clone the VM or migrate the VM to another ESXi host with vMotion if the error has not been fixed yet.
  2. Try to consolidate snapshots once again, as explained above.

If these actions didn’t help, try to shut down the VM, open VM settings, select the VM options tab, then expand the Advanced section, and click Edit Configuration. In the Configuration parameters window, click Add Configuration Params. Add the asyncConsolidate.forceSync parameter and set this parameter to TRUE.

Sometimes the virtual machine consolidation needed status can be caused by inconsistent -ctk.vmdk files that are created for changed block tracking (by VM backup software, for example). Try to delete CTK files. They are not needed for snapshot consolidation. Don’t forget to back up VM files before deleting CTK files. Then try to consolidate virtual machine disk files again.

Editing VM configuration parameters for VMware disk consolidation

The Consolidate option is inactive

If the VMware consolidate snapshot option is greyed out (inactive), an active task can be running on the VM now. If you see the “detected an invalid snapshot configuration” error, some snapshots can be broken or there are split-chains of snapshots. In this case, try to do the following actions.

  1. Connect to the ESXi server via SSH and go to the directory where the VM files are located on the datastore.

cd vmfs/volumes/DatastoreName/VMFolderName

You can check the VM files’ location in the VMware vSphere Client and find the location of virtual disks by viewing VM settings.

  1. Identify what disk snapshots are being pointed:

cat VM-name.vmx | grep scsi*

See the output to check virtual disk files including virtual disk snapshot files. For example, the name of the virtual disk file is displayed in the line. This is not a snapshot:

scsi 0:0.fileName = “VM-Name.vmdk”

In the output line, the name of the virtual disk snapshot file is displayed, and you are pointing the snapshot:

scsi 0:0.fileName = “VM-Name-000002.vmdk”

A SCSI virtual disk controller is used in VM configuration in this example.

  1. The next command checks what each snapshot is pointing to. Use this command to detect which snapshot is pointing to the next disk file (the snapshot vmdk file or a base disk vmdk file) in the snapshot chain.

cat VM-Name-000002.vmdk | grep parentFileNameHint

You may need to execute this command again for other vmdk files (like VM-Name-000001.vmdk in this example) until you find the needed base disk. This method helps you find the inconsistency.

  1. If you have found the inconsistency, for example, VM-Name-000002.vmdk is pointing to VM-Name-000001.vmdk which is pointing to VM-Name.vmdk, run vmkfstools on the highest point of the disk snapshot chain (VM-Name-000002.vmdk in this case):

vmkfstools -q -v10 VM-Name-000002.vmdk

This command tries to open and close all vmdk files in the chain and notifies you where failure occurs.

Using PowerCLI

As an alternative to executing VMware disk consolidation in the VMware vSphere Client graphical user interface, you can use vSphere PowerCLI with the command line interface.

  1. Connect to the vCenter Server that manages the ESXi host with the VM that has the virtual machine consolidation needed status. Enter credentials when prompted.

Connect-VIServer vcenter01.test.com

  1. Get the list of VMs with the virtual machine consolidation needed status:

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

  1. Perform VMware disk consolidation.

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

Conclusion

This blog post has explained recommendations that can help you fix the virtual machine consolidation needed status. VMware virtual machine disks consolidation is usually needed when one of the snapshots is corrupted, a snapshot chain is inconsistent, or a snapshot is locked by another ESXi host.

Regularly run a VM backup in your VMware vSphere environment. If you have data backup, you can restore the data and resume working if data is deleted, corrupted, encrypted by ransomware or if you see an error occurred during vCenter operation. The VMware vCenter Server should be backed up, just like other important VMs. Consider using NAKIVO Backup & Replication – professional backup product that supports backing up virtual machines in VMware vSphere.

Обновлено 07.06.2022

virtual machine disks consolidation is needed

Добрый день уважаемые читатели, сегодня расскажу как решается ошибка висящая на виртуальной машине в ESXi 5.5 и звучит она virtual machine disks consolidation is needed. Если перевести это дословно, то вас культурно просят восстановить целостность виртуальной машины, так как это не совсем хорошо, из за этого она может очень сильно проседать по производительности, и как следствие все сервисы в ней.

Устраняем virtual machine disks consolidation is needed в ESXI 5

Вот так вот выглядит эта ошибка, некое такое предупреждающее сообщение на вкладке Summary.

Ошибка virtual machine disks consolidation is needed в ESXI 5.x.x-01

Ошибка virtual machine disks consolidation is needed в ESXI 5.x.x-01

Возникла ошибка virtual machine disks consolidation is needed в ESXI 5.x.x, причина это удаление snapshot. После его удаления остались файлы которые не смогли слиться с основным файлом виртуального диска, и требуется провести консолидацию. Выбираете нужную машину правым кликом меню Power-Consolidate.

Ошибка virtual machine disks consolidation is needed в ESXI 5.x.x-02

Ошибка virtual machine disks consolidation is needed в ESXI 5.x.x-02

После чего произойдет слияние дисков, и предупреждение пропадет. Сам процесс слияние или merge может идти долго, все будет зависеть от некоторых факторов

  • Загруженность виртуальной машины
  • Ее размер
  • Количество снапшотов, которые нужно консолидировать

У меня были случаи в практике, что виртуалка так консолидировалась 3 дня.

Устраняем virtual machine disks consolidation is needed в vCenter 7

На текущий момент у меня гипервизоры ESXI 7, тут эта ошибка так же легко встречается.

virtual machine disks consolidation is needed в vCenter 7

Тут принцип устранения такой же, выключите виртуальную машину и откройте контекстное меню «Snapshot — Consolidate«.

Консолидация диска в vCenter 7

Дожидаемся когда закончиться наше задание консолидации.

Процесс консолидации дисков

После завершения задания убедитесь, что статус «virtual machine disks consolidation is needed» пропал.

Успешная консолидация дисков

Что делать, если штатная консолидация не помогла

Вот интересная ситуация, вроде бы задание отработало, но вот статус у виртуальной машины остался «Virtual machine disks consolidation is needed», лишь цвет предупреждения сменился на уведомительный.

Virtual machine disks consolidation is needed

Тут проблема в том, что если вы на уровне датастора посмотрите файлы виртуальной машины, то сможете обнаружить, что там много файлов от снимков.

Список снапшотов в файлах виртуальной машины

Чтобы это поправить, вам необходимо в ручном режиме, создать снапшот и затем его просто удалить. Это позволит механизму обнаружить все имеющиеся снимки и объединить их.

Создание снапшота в vCenter 7

Как объединить снимки из PowerCLI

Все эти же действия можно сделать и через PowerCLI, как его устанавливать смотрите по ссылке слева. Первое, что делаем, это подключаемся или к хосту или к vCenter серверу. Далее нам нужно получить список виртуальных машин с остатками от снимков. Чтобы получить список виртуальных машин, сообщающих о проблеме «Требуется консолидация дисков виртуальных машин», мы можем вызвать командлет Get-VM, чтобы определить, требуется ли консолидация виртуальных машин.

$VMs = Get-VM | Where-Object {$_.ExtensionData.RunTime.ConsolidationNeeded}

Далее выведем просто $VMs. В моем примере нашлось несколько виртуальных машин, где требуется консолидация.

объединение дисков виртуальных машин powercli

Теперь, чтобы объединить диски, вам нужно выполнить:

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

или
ForEach ($VM in $VMs)

{ (Get-VM $VM).ExtensionData.ConsolidateVMDisks() }

Надеюсь вам помогла эта заметка и вы смогли устранить ошибку virtual machine disks consolidation is needed

Скрипт PowerShell для проверки и уведомлений по данной ошибке

Описанный ниже скрипт выполняет такие задачи:

  • 1️⃣Ведет лог с долгохранящимися снапшотами и дисками в статусе «disks consolidation is needed»
  • 2️⃣Проверяет снапшоты старше 30 дней
  • 3️⃣Проверяет виртуальные машины на предмет статуса «disks consolidation is needed»
  • 4️⃣отправляет на почту таблицу с результатами критериев

# Создаем папку с логами если ее нет и будим писать лог файл с датой в виде имени сюда
function Date {Get-Date -Format «yyyy.MM.dd HH:mm:ss»}

$log_folder = «$PSScriptRootLogs» + $($MyInvocation.MyCommand.Name -replace («.ps1», «»))
$log = «$log_folder$(Get-Date -Format «yyyy_MM_dd_HH_mm_ss»).txt»

# Объявляем имя vCenter сервера
$viserver = «vcenter.root.pyatilistnik.org»

###

if (! (Test-Path $log_folder -ErrorAction SilentlyContinue))
{
New-Item $log_folder -ItemType D -Force
}

### Подгружаем VMware.PowerCLI модуль

«$(Date) Start Processing» | Tee-Object $log -Append

«$(Date) Trying to import VMware.PowerCLI module» | Tee-Object $log -Append
try {
Import-Module VMware.PowerCLI -ErrorAction Stop
}
catch {
«$(Date) $($_.exception.message)» | Tee-Object $log -Append
Break
}

# Соединяемся с vCenter сервером
«$(Date) Trying to connect to VIServer $viserver» | Tee-Object $log -Append

# New-VICredentialStoreItem -Host $viserver –User «pyatilistnikAdmin» –Password «*****»
# Get-VICredentialStoreItem
try {
Connect-VIServer -Server $viserver -Force -ErrorAction Stop #-User pyatilistnikAdmin
}
catch {
«$(Date) $($_.exception.message)» | Tee-Object $log -Append
Break
}

### Получаем виртуальные машины у которых снапшоту более 30 дней

«$(Date) Trying to get list of VM Snapshots older than 30 days» | Tee-Object $log -Append
$snapshots = $null
try {
$snapshots = Get-VM | Get-Snapshot | ? {$_.created -le (Get-Date).AddDays(-30)}
}
catch {
«$(Date) $($_.exception.message)» | Tee-Object $log -Append
Break
}

«$(Date) Total snapshots: $($snapshots.Length)» | Tee-Object $log -Append

### Проверка дисков на предмет необходимости консолидироваться

«$(Date) Trying to get list of VM where disk consolidation is needed» | Tee-Object $log -Append
$vms_cons_needed = $null
try {
$vms_cons_needed = Get-VM | ? {$_.Extensiondata.Runtime.ConsolidationNeeded}
}
catch {
«$(Date) $($_.exception.message)» | Tee-Object $log -Append
Break
}

###

$snapshots_data = @()

foreach ($snapshot in $snapshots)
{
$snapshot_data = New-Object PSObject

$snapshot_data | Add-Member -MemberType NoteProperty -Name «VM» -Value $snapshot.VM
$snapshot_data | Add-Member -MemberType NoteProperty -Name «Description» -Value $snapshot.Description
$snapshot_data | Add-Member -MemberType NoteProperty -Name «Created» -Value $(Get-Date $snapshot.Created -Format «dd.MM.yyyy»)
$snapshot_data | Add-Member -MemberType NoteProperty -Name «Size, GB» -Value $([math]::Round($snapshot.SizeGB, 1))

# $snapshots | select VM, Description, Created, SizeGB | ConvertTo-Html

$snapshots_data += $snapshot_data
}

###

$vms_cons_needed_out = @()

foreach ($vm in $vms_cons_needed)
{
$vm_consolitation_needed = New-Object PSObject

$vm_consolitation_needed | Add-Member -MemberType NoteProperty -Name «Name» -Value $vm.Name

$vms_cons_needed_out += $vm_consolitation_needed
}

### Формируем список получателей

if ($snapshots.Length -gt 0)
{
$from = «tech@tech.pyatilistnik.org»
$to = «semin@pyatilistnik.org»#
# $cc1 = «test2@pyatilistnik.org»
# $cc2 = «semin@pyatilistnik.org»
# $cc3 = «test2@pyatilistnik.org»
$Subject = «Check important VM Info»
$smtpserver = «tech.pyatilistnik.org»
$secure = $true
$port = 587 # TLS, for SSL use 465
$username = «tech»
$password = ‘*********’

$Header = @»

# Формируем таблицу с данными
<style>
TABLE {border-width: 1px; border-style: solid; border-color: black; border-collapse: collapse;}
TD {border-width: 1px; padding: 3px; border-style: solid; border-color: black;}
TH {border-width: 1px; padding: 3px; border-style: solid; border-color: black;}
</style>
«@
$body = $null
$body += «<p>VM Snapshots older than 30 days:»

$body += $snapshots_data | select VM, Description, Created, «Size, GB» | ConvertTo-Html -Head $Header

$body += «<p>Also check VMs where disk consolidation is needed:»

$body += $vms_cons_needed_out | select Name | ConvertTo-Html -Property «Name» -Head $Header

$body += «<p>Generated on $($env:COMPUTERNAME + «.» + $((Get-WmiObject Win32_ComputerSystem).Domain))»

$message = New-Object System.Net.Mail.MailMessage
$message.From = $from
$message.To.Add($to)
# $message.CC.Add($cc1)
# $message.CC.Add($cc2)
# $message.CC.Add($cc3)
# $message.CC.Add($cc4)
$message.Subject = $Subject
$message.Body = $body
$message.IsBodyHtml = $true

$smtp = New-Object Net.Mail.SmtpClient($smtpserver, $port)
$smtp.EnableSsl = $secure
$smtp.Credentials = New-Object System.Net.NetworkCredential($username, $password)

«$(Date) Trying to send e-mail notification» | Tee-Object $log -Append

try {
$smtp.Send($message)
}
catch {
«$(Date) $($_.exception.message)» | Tee-Object $log -Append
}
}

###

«$(Date) End Processing» | Tee-Object $log -Append

На выходе вы будите получать вот такого рода таблицу.

скрипт disks consolidation is needed

Дополнительно

Может быть ситуация, что вы используете прокси Veeam, для ускорения резервного копирования и в нем могут застревать диски, которые будут приводить к проблеме консолидации.

A lot of users receive the “virtual machine disks consolidation is needed” error when using the VMware vSphere client. What causes the error? How to fix it? Now, let’s start exploring the answers together with MiniTool.

VMware vSphere is a virtualization software application that works as a complete platform for managing your virtual machine. It can be used to perform many virtual machine tasks such as shut down the guest OS, launch console, edit settings, create snapshots, and so on. However, many users encounter the “virtual machine disk consolidation is needed” error when using the software.

virtual machine disks consolidation is needed

According to user reports from different forums and communities, the “virtual machine disks consolidation is needed” error mainly occurs when merging multiple virtual disk files into a single disk. Here’s a true example from the Nakio forum.

Hi, guys! I’ve got this error message saying: «VMware virtual machine disks consolidation is needed.» Do you have any idea what I can do with it? Thanks!https://forum.nakivo.com/index.php?/topic/7815-vmware-virtual-machine-disks-consolidation-is-needed-error/#comment-9528

Possible Causes of the “Virtual Machine Disks Consolidation Is Needed” Error

Virtual disk consolidation is a process of merging virtual disk files created after taking the snapshots in a VM. In most cases, performing a disk consolidation is to avoid performance degradation or solve some issues.

When taking a snapshot, you will find that a delta disk is created and changes are written to the corresponding delta disk. As a result, each delta disk contains all changes made as compared to the previous delta disk state and the parent disk remains unchanged, which causes the redundant data in the virtual machine.

As the snapshots and related virtual disk files grow larger and larger, you may experience performance degrades. But after you initiate the VMware disk consolidation successfully, all data from the delta disk will be merged to a single disk and no redundant data is left on the disk where the VM files are located. That is to say, disk space will be cleaned after you consolidate virtual disk files.

However, the virtual machine disk consolidation process is not always smooth. A great many people encounter the “VMware virtual machine disk consolidation is needed” error. Why? It can be caused by many possible reasons. Here we list them as follows:

  • Deleting the VM snapshots incorrectly is the main reason behind the “virtual disk consolidation is needed” error. If you delete the snapshot improperly, the VMDK files related to snapshots and log files will leave on the datastore.
  • Poor performance of the storage system attached to an ESXi host on which a VM is running. If the snapshot size is larger or times out, the virtual disk consolidation can fail.
  • Not enough disk space on the VMFS datastore to perform the virtual disk consolidation. Usually, it requires 1 GB of free space at least on the datastore.
  • Connection issues between the VMware center and an ESXi host.
  • Snapshot files are locked by a third-party application. According to user reports, this often occurs when a backup application (like HP Data Protector, Veeam, and Netapp VSC) didn’t complete a backup or locked the snapshots.

Now, you should have known the possible causes of the “virtual machine consolidation needed status” error. Let’s see how to fix it.

How to Fix the “Virtual Machine Disks Consolidation Is Needed” Error

After analyzing all possible causes of the “VMware virtual machine disk consolidation is needed” error, we explore the following 5 applicable fixes. Here you can try them in order until the issue gets resolved.

Fix 1. Consolidate Virtual Machine Disk Files Correctly

The first and simplest fix for the “virtual machine consolidation needed status” error is to make sure that you consolidate the virtual machine disk files correctly. To do so, follow the detailed steps below:

Step 1. Launch the VMware vSphere client on your computer.

Step 2. Right-click the VM name in which you want to consolidate disk files and select Snapshots > Consolidate from the sub-menu.

select Snapshots and Consolidate in VM

Step 3. Then you will receive a confirmation message saying “This operation consolidates all redundant redo logs on your virtual machine. Are you sure you want to continue?”. Click on Yes to confirm the VMware disk consolidation.

Note: If you are concerned that some data get lost during the disk consolidation process, you can make a VMware virtual machine backup. For instance, you can transfer all VM filers into another folder on a datastore.

click Yes to confirm the VMware disk consolidation

Then the vSphere client will consolidate virtual disk files and clear the logs. The time needed for the process depends on the VM size, the number of snapshots, and VM load. Once completed, the “virtual machine consolidation needed status” error should disappear.

Fix 2. Delete All Existing VM Snapshots

Another main reason for the disk consolidation error is the locked VM files. If you receive another error message “Unable to access file since it is locked. An error occurred while consolidating disks” during the process, this indicates that your VM disk files are locked by a backup application. In this case, you need to unlock VM files by following Fix 2 or Fix 3. Here we will show you how to unlock VM files by deleting all snapshots.

Step 1. Shut down the virtual machine that you are running and create a new VM disk snapshot.

Step 2. Right-click the VM tab from the top menu, and then select Snapshots and click on Delete All Snapshots.

Step 3. Sometimes the virtual machine consolidation needed status can be triggered by inconsistent -ctk.vmdk files. So, you can try deleting the CTK files.

Step 4. Now, you can try reconsolidating virtual disk files again as we explain above.

Tip: If these steps didn’t help, you can shut down the VM, open VM settings, select the VM Options tab, and then expand the Advanced category and click on Edit Configuration. In the configuration window, click on Add Configuration Params, add the asyncConsolidate.forceSync parameter, and set it to TRUE.

Fix 3. Move the VM to Another ESXi Host

The locked VM files created by a backup application are mainly used to avoid the concurrent writes to the files by multiple ESXi hosts. However, these locked disk files can trigger the virtual disk consolidation is needed error. To unlock the file, you can move the VM to another ESXi host.

Step 1. Restart the management agents on the ESXi host on which the VM resides. To do so, you can open the ESXi shell or connect to the ESXi host via SSH and run the commands below as root:

services.sh restart

or

/etc/init.d/hostd restart

/etc/init.d/vpxa restart

Tip: You can also open the ESXi direct console by navigating to Troubleshooting Options, and selecting Restart Management Agents (by pressing Enter to activate the needed option and pressing F11 to confirm.)

Step 2. Now, you can check the locked VM files by running the command below:

vmfsfilelockinfo -p /vmfs/volumes/vm_datastore/vm_name/vm_name.vmx

Step 3. Check the hosted log files if you want to identify the path on the datastore in which VM files reside.

cat /var/log/hostd.log |grep -i vm_name

Step 4. Navigate to the VM directory on the datastore after you get the VM files’ location:

cd /vmfs/volumes/datastore_name/vm_name

Step 5. Apply the following command to list the ESXi hosts locked by the VM 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

Step 6. Restart your ESXi management agents (including hosted and vpxa). Then run the command below on the EXSi host to unlock the VM files.

/etc/init.d/hostd restart

/etc/init.d/vpxa restart

Once done, you can consolidate virtual machine disk files again and see if the error still appears.

Fix 4. Extend Your Disk Space

As mentioned above, the “VMware virtual machine disk consolidation is needed” error can occur due to insufficient disk space. So, we recommend you check if there is enough free disk space (more than 1 GB) on the VMFS datastore. If not, you need to extend the disk space.

If you don’t want to delete any files on the VFMS datastore, extending disk space is a good choice. How to extend disk drive without data loss? As a multifunctional partition manager, MiniTool Partition Wizard can help you do that easily. In addition, it can be used to analyze disk space, convert NTFS to FAT, migrate OS, recover lost data, etc.

Free Download

Here’s how to extend the partition with the MiniTool utility.

Step 1. Launch this software to enter its main interface, and then select the disk drive where the VMFS datastore resides and click on Extend Partition from the left pane.

Step 2. Select the drive that you want to take free space from, and then drag the slider bar to occupy the free space or input the specific volume based on your demands. Then click on OK.

Step 3. Click on Apply to execute the process.

expend partition using MiniTool Partition Wizard

Fix 5. Use an Alternative to Execute the VMware Disk Consolidation

If you still receive the VMware disk consolidation error after trying all the above methods, you may consider using an alternative called vSphere PowerCLI to consolidate virtual disk files. The PowerCLI is a graphical user interface that can extend PowerShell to understand and interact with VMware environments. Here’s how to use it to consolidate virtual disks.

Step 1. Launch the PowerCLI client, connect to the vCenter Server that manages the ESXi host with the VM, and enter credentials when you’re prompted.

Connect-VIServer vcenter01.test.com

Step 2. Run the following command below to get the list of VMs with the virtual machine consolidation needed status.

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

run a command in PowerCLI

Step 3. Now, you can consolidate virtual machine disk files by executing the command below.

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

When I’m trying to consolidate virtual disks with the VMware vSphere client, an error “virtual machine disks consolidation is needed” popped up. Fortunately, I fixed the error with the help of this post.Click to Tweet

What’s Your Opinion

How to fix the “virtual disk consolidation is needed” error? Now, you can try any or all of the 5 fixes I have explained above and see which one works best for you. If you have better solutions to the error, please write them down in the comment area. Also, you can send us an email to [email protected] when you have any difficulties in using the MiniTool software.

The warning ‘VMWare: virtual machine disks consolidation is needed’ indicates that while deleting a snapshot, the snapshot VMDK files or logs have not been deleted correctly.

Here at Bobcares, we have seen several such VMWare related errors as part of our Server Management Services for web hosts and online service providers.

Today we will take a look at the causes for this error and see how to fix it.

What causes ‘VMWare: virtual machine disks consolidation is needed’ warning to appear

Here are the different causes of this VMWare error to occur.

1. Snapshots can’t be deleted due to poor storage performance. It happens due to a timeout or a large size of a snapshot.
2. No enough space on the VMFS store to perform consolidation
3. If the vSphere or a third-party app has locked snapshot files. So ensure that there are no running processes of a virtual machine backup.
4. Having any connection issues between the vCenter Server and the ESXi host.

How we resolve ‘VMWare: virtual machine disks consolidation is needed’ warning

Now let’s see how our Support Engineers assist our customers in resolving this warning message.

First, right-click on the virtual machine and select VM >> Snapshots >> Consolidate.

Then a window with the below request appears.

vmware: virtual machine disks consolidation is needed

Here, click on Yes to confirm that you want to delete the redundant logs. As a result, the vCenter will consolidate disks and clear the logs. It might take a few minutes for the consolidation to take place and the VM performance may degrade.

Finally, the warning of the VM consolidation must disappear.

In a few cases, you may see the below error in the vSphere console during consolidation.

vmware: virtual machine disks consolidation is needed

In such a case, VMWare recommends restarting Management agents on the ESXi server. To do it, run the below command after connecting to the host via SSH.

services.sh restart

Moreover, you can try unlocking the VM files as follows.

1. If possible, shut down the VM.
2. Try creating a new snapshot.
3. Using the ‘Delete All’ option, delete all the VM snapshots.
4. Using vMotion, move the VM to another ESXi.
5. Try consolidating the snapshots as described above.

You can also find all the virtual machines that require consolidation using PowerCLI. To do it, connect to your vCenter server:

Connect-VIServer mun_vsphere.woshub.com

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

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

After that, you must consolidate the disks of all machines in the list:

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

[Need any further assistance in fixing VMWare errors? – We are here to help you]

Conclusion

In short, this warning indicates that while deleting a snapshot, the snapshot VMDK files or logs have not been deleted correctly. Today, we saw the solution provided by our Support Engineers to this error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = «owonCMyG5nEQ0aD71QM»;

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()
}

Понравилась статья? Поделить с друзьями:
  • Ошибка консоли управления mmc 1с
  • Ошибка кондиционера защита от высокого давления
  • Ошибка кондиционера е5 варианты исправления
  • Ошибка кондиционера е4 после чистки
  • Ошибка кондиционера gree e9 как исправить