"Unable to create a swap file. The value of 'sched.swap.dir' specified in the VM's configuration file is invalid" error in ESXi Host.
search cancel

"Unable to create a swap file. The value of 'sched.swap.dir' specified in the VM's configuration file is invalid" error in ESXi Host.

book

Article ID: 334312

calendar_today

Updated On: 02-20-2025

Products

VMware vSphere ESXi

Issue/Introduction

To resolve this issue, update the sched.swap.dir to the new datastore manually.

Symptoms:
After migrating the datastore of a virtual machine, you experience these issues:

  • Unable to power on the virtual machine.
  • You see the error:

An unexpected error was received from the ESX host while powering on VM vm-xxxxx.
Failed to power on VM.
Unable to create a swap file. The value of 'sched.swap.dir' specified in the VM's configuration file is invalid.

  • Migrating the virtual machine to the original datastore resolves the issue.



Environment

  • VMware vSphere ESXi 6.x / 7.0 / 8.0

Cause

This issue occurs when the path set in the option sched.swap.dir is not updated in the .vmx configuration file of the virtual machine after migrating it to the new datastore.

Resolution

To resolve this issue, manually update sched.swap.dir to reflect the new datastore:
  1. Connect to the ESXi host with an SSH session using root credentials. For more information, see Using ESXi Shell in ESXi.
  2. Navigate to the virtual machines directory on the ESX host by running this command:
    # cd /vmfs/volumes/<datastore>/<virtual_machine>/
  3. create a backup of the .vmx file:
    # cp <virtual_machine>.vmx <virtual_machine>.vmx_bak
  4. Open the .vmx file using a text editor:
    # vi <virtual_machine>.vmx
  5. Find the sched.swap.dir entry and update it the path to match the new virtual machine datastore.
    For example: 
    sched.swap.dir = /vmfs/volumes/datastore1/testvm/
  6. Reload the virtual machine on the ESXi host. For more information, see Reloading a vmx file without removing the virtual machine from inventory.
  7. Power on the virtual machine.



Additional Information