Could not power on VM : No swap file. Failed to power on VM

When the ESX server get unexpected restart, it might happen that some of  the VMs has a problem with Power on due to file lock.

Failed to power on VM Could not power on VM : Lock was not free.
Failed to initialize swap file ‘/volumes/4d8a07c2-b63cce23-a467-d8d385b8f298/vm01/vm01-3473aa90.vswp’ : Lock was not free

or other similar error :

Failed to power on VM. Could not find swap file.

What to do it that case ? Find out which server keeps a lock on files, move VM to that server and power it on.

  1. We have to find out which server keeps file locked.
    Log in to server via ssh, navigate to datastore and folder with virtual machine files, type – touch out put should be: device or resource busy
  2. next step is to identify MAC address of the server which keeps file locked, from a command prompt type  vmkfstools -D which will send all info to vmkernel log
  3. Next, tail /var/log/vmkernel and search for expression after word owner   (see picture below,  arrow with rectangle). last 12 figures is a MAC address of the service console from server which keeps  file locked.
  4. When MAC address is known, is easy to find  a server which keeps a lock, log in to ESX servers over ssh and execute command: ifconfig | grep -i hw
    As you can see on above figure, MAC address corresponding to expression from vmkernel log. Guilty server was found 🙂
  5. Perform  vMotion of problematic VM to server which keeps the lock and power VM on.

 

Artur Krzywdzinski

Artur is Consulting Architect at Nutanix. He has been using, designing and deploying VMware based solutions since 2005 and Microsoft since 2012. He specialize in designing and implementing private and hybrid cloud solution based on VMware and Microsoft software stacks, datacenter migrations and transformation, disaster avoidance. Artur has been in IT industry since 1999 and consulting since 2008. Artur holds VMware Certified Design Expert certification (VCDX #077).