"Error: Failed to initialize swap file" powering on a virtual machine
search cancel

"Error: Failed to initialize swap file" powering on a virtual machine

book

Article ID: 342632

calendar_today

Updated On:

Products

VMware vCenter Server VMware vSphere ESXi

Issue/Introduction

This article provides information to troubleshoot and fix problems when a VM fails to powering on due to swap file problems.

Symptoms:

  • Virtual machine (VM) fails to power on with the error:
Error: Failed to initialize swap file
  • The ESXi hostd.log shows messages similar to the below for the affected VM:
    YYYY-MM-DDTHH:MM:SS.538Z verbose hostd[2101409] [Originator@6876 sub=Vigor.Vmsvc.vm:/vmfs/volumes/DatastoreName/VMFolder/VM.vmx opID=esxui-aaaa-2140] Power On message: Module 'MonitorLoop' power on failed.
    --> Directory entry insert operation failed on <FD c0 r9> with: Already exists.
    --> File system specific implementation of CreateFile[file] failed
    --> Failed to initialize swap file '/vmfs/volumes/DatastoreName/VMFolder/VM.vswp' : Not found
    --> Could not power on virtual machine: Not found.
    --> Failed to power on VM.
    --> Failed to start the virtual machine.
    -->

Environment

VMware vSphere 8.x
VMware vSphere 7.x
VMware vSphere 6.x

Cause

This issue can be caused by:
  • The datastore is out of space
  • File lock issues
  • Datastore issues

Resolution

  1. Verify the datastore has enough space to run the VM.
Note: The VM's swap file is normally the same size as the memory allocated to it
  1. Right-click the virtual machine in the vCenter or ESXi UI, select Edit Settings...
  2. Make note how much memory has been allocated to the VM
  3. If remaining datastore space is less than the size of the VM memory, some options are to:
    • Move the VM's swap file location to a different datastore, see Swap File Location
    • Clear space by consolidating VM snapshot files
    • Storage vMotion VMs to a different datastore to free space
    • Reduce the allocated memory for the VM
Note: this can cause performance problems for the VM's applications if inadequate. consult the application vendor if needed
  • Add space to the datastore
  1. Connect to the ESXi host the VM resides
    1. See Remote ESXi Shell Access with SSH
    2. Navigate to the VM's directory:
ls -lha
  1. If there are I/O errors with that command,
    1. Troubleshoot the datastore for any integrity issues.
    2. Restore or rebuild VM on a healthier datastore
  2. Look at vmware.log for this VM to see if there are any input/output errors:
cat vmware.log |less
  1. If there are input/output errors:
    1. Try to storage vMotion the VM
    2. Troubleshoot datastore problems, or
    3. Restore or rebuild the VM to healthier datastore
 
  1. If there are no I/O errors, check the VM's directory if the .vswp file already exists
    1. Remove the .vswp file:
rm *.vswp
  1. If the files fails to delete:
    1. Check the storage array for errors
    2. Migrate, restore or rebuild VM to healthier datastore

  2. If the .vswp file is removed re-try powering on the VM.
 
  1. If the issue persists, see Investigating virtual machine file locks on ESXi hosts



Additional Information

VMX Swap Files
Using Swap Files
Failed to power on virtual machine


Impact/Risks:
Swap file problems prevent VMs from being able to power on
Reducing virtual machine memory can cause performance problems with guest operating system applications