"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
  • In the vmware.log for the VM, you see errors creating the swap file.


Environment

VMware vCenter Server Appliance 6.5.x
VMware vSphere ESXi 6.5
VMware vCenter Server Appliance 6.7.x
VMware vSphere ESXi 6.7
VMware vCenter Server Appliance 6.0.x
VMware vSphere ESXi 7.0.0
VMware vCenter Server 7.0.x
VMware vCenter Server 6.0.x
VMware vCenter Server 6.5.x
VMware vCenter Server 6.7.x
VMware vSphere ESXi 6.0

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 your application vendor if needed
  • Add space to the datastore
  1. Check for input/output errors when listing VM files from host
    1. Connect to the ESXi host the VM resides, see Connecting to an ESX host using an SSH client
    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 you see 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