{"id":980,"date":"2012-04-30T09:00:05","date_gmt":"2012-04-30T13:00:05","guid":{"rendered":"http:\/\/enterpriseadmins.org\/blog\/?p=980"},"modified":"2012-04-22T14:44:41","modified_gmt":"2012-04-22T18:44:41","slug":"power-on-virtual-machine-unable-to-access-file-since-it-is-locked","status":"publish","type":"post","link":"https:\/\/enterpriseadmins.org\/blog\/scripting\/power-on-virtual-machine-unable-to-access-file-since-it-is-locked\/","title":{"rendered":"Power On virtual machine &#8211; Unable to access file since it is locked"},"content":{"rendered":"<p>Several times in the past few weeks I have ran into virtual machines that do not power on because of locked files.  Steps to troubleshoot this issue are described in KB10051: <a href=\"http:\/\/kb.vmware.com\/kb\/10051\">Virtual machine does not power on because of locked files<\/a>.  While looking into this topic, I found the following article on vi-tips.com <a href=\"http:\/\/www.vi-tips.com\/2012\/04\/could-not-power-on-vm-lock-was-not-free.html\">Could not power on VM &#8211; lock was not free<\/a>, which describes the same issue.  My issue was encountered on several ESXi 5.0 Update 1 hosts, and according to this vi-tips.com article the issue also exists on ESXi 4.1.<\/p>\n<p>The vi-tips.com post includes several screenshots of how to isolate\/troubleshoot this issue.  After a few steps, you can use <strong><em>vmkfstools -D \/vmfs\/volumes\/sanvolname\/filename-flat.vmdk<\/em><\/strong> to determine the MAC address of the VMKernel interface maintaining the lock.  A little bit of PowerCLI goes a long way into finding which host uses this interface:<\/p>\n<pre><code class=\"language-1\">\r\nFunction Get-VMHostNameByMac ([string]$macAddress) {\r\n#The MAC address passed to this function does not need separators, we will remove them if provided\r\n$macAddress = $macAddress.Replace(\":\",\"\").Replace(\"-\",\"\")\r\n\r\n#The MAC property returned by the Get-VMHostNetworkAdapter cmdlet will have a colon separator, so we will remove it for comparison purposes\r\nGet-VMHost | Get-VMHostNetworkAdapter | where {$_.Mac.Replace(\":\",\"\") -eq $macAddress} | select-Object VMHost, Name, MAC\r\n}\r\n<\/code><\/pre>\n<p>Here is example usage of this command:<\/p>\n<pre>Get-VMHostNameByMac '001ec9123456'<\/pre>\n<p>Once the locking VMKernel interface is located, we can continue troubleshooting.  The vi-tips.com article suggests cold migration of the VM to the locking host and powering on the virtual machine on that host &#8212; but I was unable to get that option to work.  However, I found that restarting the management agents on the locking host would resolve my issues.  Once the management agents were restarted I could power on the VM using any host. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Several times in the past few weeks I have ran into virtual machines that do not power on because of locked files. Steps to troubleshoot this issue are described in KB10051: Virtual machine does not power on because of locked &hellip; <a href=\"https:\/\/enterpriseadmins.org\/blog\/scripting\/power-on-virtual-machine-unable-to-access-file-since-it-is-locked\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-980","post","type-post","status-publish","format-standard","hentry","category-scripting","category-virtualization"],"_links":{"self":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/980","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/comments?post=980"}],"version-history":[{"count":8,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/980\/revisions"}],"predecessor-version":[{"id":988,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/980\/revisions\/988"}],"wp:attachment":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/media?parent=980"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/categories?post=980"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/tags?post=980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}