Bobcares

How to fix “Unable to access a file since it is locked” error in VMWare?

by | Oct 20, 2020

Deleting snapshots or consolidating disks of the virtual machines often triggers the “Unable to access a file since it is locked” error on VMWare ESXi hosts.

As a part of our Server Management Services, we help our Customers to fix VMWare related errors regularly.

Let us today discuss the possible causes and fixes for this error.

What is VMWare Error: Unable to access a file since it is locked?

While deleting a snapshot or consolidating disks of virtual machines running on VMWare ESXi hosts, it often triggers the error message “Unable to access a file since it is locked”.

A typical error message may look like:

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

Another common form of this error is :

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

Common reasons for this error include:

  • Powered up virtual machine contains some files with tags indicating that they are in use  by other ESXi hosts
  • The backup session fails after adding virtual disks to the backup appliance.

How to fix VMWare Error: Unable to access a file since it is locked?

To fix this error, we need to find the source of a lock and release it. For this, the initial step is to identify the locked files.

    1. First, using an SSH client, connect to the ESXi host for the problem VM.
    2. Now, 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:
      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
    5. Here, the file mun-web01_1-000002.vmdk is locked. Use the command below to display the current snapshot chain starting with the specified one to a flat disk:
      vmkfstools -qv10 mun-web01_1-000002.vmdk
    6. 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 locked the snapshot file. Also, note the Mode value:

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

Now, to find an ESXi server from the MAC address obtained, we can use the following PowerCLI commands:

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 *

It will show the ESXi hostname in the VMHost field.

Further, we 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

To unlock a VM file, just restart the ESXi host we found. If we cannot restart the host, we can 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.

[Need any further assistance to delete snapshots or consolidate disks of your virtual machine? – We’re available 24*7]

Conclusion

In short, restarting the ESXi host or Management Agent can help to fix the “Unable to access a file since it is locked”  error. Today, we saw how our Support Engineers fix 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";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

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

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF