Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Virtualization / VMware / VMWare Error: Unable to Access a File Since It Is Locked

March 15, 2024

VMWare Error: Unable to Access a File Since It Is Locked

Very often when deleting snapshots or consolidating disks of virtual machines running on VMWare ESXi hosts, I see the “Unable to access a file since it is locked” error. This frequent issue is related to errors in a VM backup software (I came across the issue in Veeam, HPE/Micro Focus Data Protector, Veritas.) If the snapshot of the virtual disk is locked, you won’t be able to consolidate disks (when you see the error ‘Virtual machine disks consolidation is needed’), move a disk to another datastore using Storage vMotion, back up a VM or delete the current snapshot. Sometimes you cannot even turn on a locked virtual machine.

An error of access to a locked virtual disk file or a snapshot in VMWare may look like this:

Unable to access file since it is locked.
An error occurred while consolidating disks: One or more disks are busy.

vmware error Unable to access file since it is locked.

Also, you may see this error:

An error occurred while consolidating disks: msg.snapshot.error-DISKLOCKED.

The most often the “Unable to access file since it is locked” error appears when:

  • Some files of a powered on virtual machine contain tags indicating that they are locked by other ESXi hosts;
  • When virtual disks are added to the backup appliance and the backup session fails.

To find the source of a lock and release it, you have to identify the locked files first.

  1. Using an SSH client, connect to the ESXi host prompt the problem VM is registered on;
  2. Go to the directory with the virtual machine files: cd /vmfs/volumes/VMFS_DATASTORE_NAME/LOCKED_VM
  3. Look for consolidation and file locking errors in vmware.log: cat vmware.log | grep lock
  4. The log will contain errors like that:
    VigorSnapshotManagerConsolidateCallback: snapshotErr = Failed to lock the file (5:4008)
    2020-09-09T05:07:11.432Z| vmx| I125: DISK: Cannot open disk "/vmfs/volumes/5121c3ff-2303a3a-33bb-12345678221/mun-web01/mun-web01_1-000002.vmdk": Failed to lock the file (16392).
    2020-09-09T05:07:11.432Z| Worker#1| I125: DISKLIB-LIB : Failed to open '/vmfs/volumes/5121c3ff-2303a3a-33bb-12345678221/mun-web01/mun-web01-000002.vmdk' with flags 0xa Failed to lock the file (16392).
    2020-09-09T05:07:11.432Z| Worker#1| I125: DISK: Cannot open disk "/vmfs/volumes/5121c3ff-2303a3a-33bb-12345678221/mun-web01/mun-web01-000002.vmdk": Failed to lock the file (16392).
    2020-09-09T05:07:11.432Z| vmx| I125: [msg.fileio.lock] Failed to lock the file

     vmware.log Failed to lock the file

  5. In this example, you can see that the file mun-web01_1-000002.vmdk is locked;
  6. Using the following command, you can display the current snapshot chain starting with the specified one to a flat disk: vmkfstools -qv10 mun-web01_1-000002.vmdk
  7. Then get the information about the snapshot and its owner (RO owner): vmkfstools -D mun-web01-000001-delta.vmdk
Lock [type 10c000021 offset 242835456 v 856, hb offset 3153920
gen 3, mode 1, owner 5cbac61a-4b6e32b7-0480-d06726ae7900 mtime 5199410
num 0 gblnum 0 gblgen 0 gblbrk 0]
RO Owner[0] HB Offset 3153920 5cbac61a-4b6e32b7-0480-d06726ae7900
Addr <4, 532, 83>, gen 859, links 1, type reg, flags 0, uid 0, gid 0, mode 600

The RO Owner line shows the MAC address of the ESXi host network adapter that has locked the snapshot file (the MAC address is highlighted on the screenshot). Also, note the Mode value:

  • mode 1 – a read/write lock (for example, of a powered on VM);
  • mode 2 – usually means that the virtual disk is locked by the backup application.

To find an ESXi server if a MAC address is known, you can use the following VMware PowerCLI commands (convert the MAC address you got earlier to the format with colons):

Import-Module VMware.VimAutomation.Core -ErrorAction SilentlyContinue
connect-viserver mun-vcenter
Get-VMHost | Get-VMHostNetworkAdapter | Where-Object {$_.Mac -like "d0:67:26:ae:79:00"} | Format-List -Property *

powercli find vmware esxi by a MAC address

The ESXi hostname will be shown in the VMHost field.

Also, you can display the ARP table directly from the ESXi host and get IP and MAC addresses of all other ESXi servers in the VMkernel network:

esxcli network ip neighbor list

esxcli network ip neighbor - list MAC addresses

To unlock a VM file, just restart the ESXi host you have found (migrate all VMs from it using VMotion in advance). If you cannot restart the host, restart the Management Agent (hostd) in the Maintenance Mode from the host’s SSH console:

services.sh restart

Then try to consolidate disks or delete a VM snapshot again.

The “Unable to access file since it is locked” error often occurs in Veeam Backup & Replication when using a Veeam proxy server. Due to backup errors, Veeam may not unmount a virtual machine disk correctly.

To fix the problem, open the settings of the VM, Veeam proxy is installed on. Remove the disk of the VM that has locked files from the VM hardware.

Make sure that you have checked “Remove from virtual machine” instead of “Remove from virtual machine and delete files from disk” otherwise you can accidentally remove your vmdk disk.

0 comment
4
Facebook Twitter Google + Pinterest
PowerShellVirtualizationVMware
previous post
How to Enable or Disable SMB 1.0 in Windows 10/11 and Windows Server
next post
Managing System Reserved Partition in Windows 10

Related Reading

Adding External USB Storage Drive to VMware ESXi

December 18, 2024

Adding a Sound Card to a Virtual Machine...

March 15, 2024

Disable Auto Suspend of VM on VMWare Workstation/Player

August 26, 2021

Match Windows Disks to VMWare VMDK Files

March 12, 2024

How to Stop an Unresponsive (Stuck) Virtual Machine...

March 15, 2024

Configuring USB Devices Passthrough from VMWare ESXi to...

March 12, 2024

Selecting the Number of vCPUs and Cores for...

March 12, 2024

Reduce Virtual Machine Disk Size (VMDK) on VMWare...

March 22, 2024

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Configuring Windows Protected Print Mode (WPP)

    May 19, 2025
  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Download Offline Installer (APPX/MSIX) for Microsoft Store App
  • Get-ADUser: Find Active Directory User Info with PowerShell
  • How to Hide Installed Programs in Windows 10 and 11
  • Using Credential Manager on Windows: Ultimate Guide
  • Managing Printers and Drivers on Windows with PowerShell
  • PowerShell: Get Folder Size on Windows
  • Protecting Remote Desktop (RDP) Host from Brute Force Attacks
Footer Logo

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


Back To Top