Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • 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 2012
    • 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 Error: Unable to Access a File Since It Is Locked

October 1, 2020 PowerShellVirtualizationVMWare

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

A similar solution when you need to find a VM in VMWare vCenter by its IP or 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
previous post
How to Disable/Enable SMB v 1.0 in Windows 10/Server 2016?
next post
Allow RDP Access to Domain Controller for Non-admin Users

Related Reading

Using Previous Command History in PowerShell Console

January 31, 2023

How to Install the PowerShell Active Directory Module...

January 31, 2023

Finding Duplicate E-mail (SMTP) Addresses in Exchange

January 27, 2023

How to Disable or Uninstall Internet Explorer (IE)...

January 26, 2023

How to Delete Old User Profiles in Windows?

January 25, 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

  • Using Previous Command History in PowerShell Console

    January 31, 2023
  • How to Install the PowerShell Active Directory Module and Manage AD?

    January 31, 2023
  • Finding Duplicate E-mail (SMTP) Addresses in Exchange

    January 27, 2023
  • How to Delete Old User Profiles in Windows?

    January 25, 2023
  • How to Install Free VMware Hypervisor (ESXi)?

    January 24, 2023
  • How to Enable TLS 1.2 on Windows?

    January 18, 2023
  • Allow or Prevent Non-Admin Users from Reboot/Shutdown Windows

    January 17, 2023
  • Fix: Can’t Extend Volume in Windows

    January 12, 2023
  • Wi-Fi (Internet) Disconnects After Sleep or Hibernation on Windows 10/11

    January 11, 2023
  • Adding Trusted Root Certificates on Linux

    January 9, 2023

Follow us

woshub.com
  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Installing RSAT Administration Tools on Windows 10 and 11
  • Get-ADUser: Find Active Directory User Info with PowerShell
  • How to Hide Installed Programs in Windows 10 and 11?
  • Managing Printers and Drivers with PowerShell in Windows 10 / Server 2016
  • How to Create a UEFI Bootable USB Drive to Install Windows 10 or 7?
  • PowerShell: Get Folder Sizes on Disk in Windows
  • Deploy PowerShell Active Directory Module without Installing RSAT
Footer Logo

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


Back To Top