Search the VMware Knowledge Base (KB)
View by Article ID

Storing a virtual machine swap file in a location other than the default in ESX/ESXi (1004082)

  • 35 Ratings


This articles provides steps to change the default location of your virtual machines swap files.


Moving the swap file to an alternate datastore is a useful troubleshooting step if the virtual machine or guest operating system is experiencing failures, including STOP errors, read-only file systems, and severe performance degradation issues during periods of high I/O. However, identifying and resolving the underlying overcommit or storage performance issues is still recommended to ensure environment stability.

This can also be used to store the virtual machine swap files in an alternate non-replicated datastore when using LUN snapshot technologies to ensure that you are storing the swap files in a location that is not being replicated.

ESXi/ESX 3.5, 4.x, and ESXi 5.x

Note: If your hosts are part of an HA Cluster, you must change the cluster settings for virtual machine swap file location prior to executing the steps below. For more information, see the Change the Swap File Location section in the Virtual Machine Admin Guide for your version.

To edit the virtual machine swap file location in ESXi/ESX 3.5, 4.x, and ESXi 5.x:
  1. Connect directly to your host or to your vCenter Server using the VMware Infrastructure/vSphere Client.
  2. Click the Configuration tab for the ESXi/ESX host.
  3. Click Virtual Machine Swapfile Location and click Edit.
  4. Specify the datastore where you want to store the virtual machine swap files.
  5. To complete the action the virtual machine will need to be powered off, then powered on.
  6. Ensure the swap file is located on the specified host datastore.
To change the swap file location for a single virtual machine:
  1. Power off the virtual machine.
  2. Unregister the virtual machine. Right-click the virtual machine in the Inventory and choose Remove from Inventory.
  3. Connect to the host:

  4. Change directory to the folder where the virtual machine resides:

    cd /vmfs/volumes/datastore_name/virtual_machine_folder/

  5. Edit the virtual machine's configuration file with a text editor.
  6. Add this line:

    sched.swap.dir = /vmfs/volumes/datastore_name/dir_name

  7. Register the virtual machine again. For more information, see Registering or adding a virtual machine to the inventory on vCenter Server or on an ESXi/ESX host (1006160).

ESX 3.0

Add this line to your virtual machine's configuration (.vmx) file to store the swap on a VMFS-3 volume:

sched.swap.dir= "/vmfs/volumes/volume_name/dir_name"

Where volume_name is the name of a VMFS-3 volume.

To change the swap file location:
  1. Connect to vCenter Server or directly to your ESX host using the vSphere Client.
  2. Select either a virtual machine or a virtual machine template that you want to modify.
  3. Stop the virtual machine, if it is running.
  4. Connect to the ESX console using SSH or a service console connection.
  5. Change directory to the path of the .vmx file you want to edit.

    Note: Use the vmware-cmd -l command to find the path to the configuration file. For more information on the vmware-cmd command, see the VMware Scripting API.

  6. Open the configuration file in a text editor and add this line:

    sched.swap.dir= "/vmfs/volumes/volume_name/dir_name"

  7. Delete this line:

    sched.swap.derivedName = xxx

  8. To complete the action the virtual machine will need to be powered off, then powered on.
  9. Ensure the swap file is located on the specified host datastore.
  10. Repeat for each existing virtual machine, as required.

Additional Information

Virtual machine swap file location affects vMotion compatibility in different ways, depending on the version of ESXi running on the virtual machine's host. You can configure ESX/ESXi 3.5 or later hosts to store virtual machine swap files along with the virtual machine configuration file or on a local swap file datastore specified for that host. The impact of the location of the virtual machine swap file on vMotion compatibility includes these:
  • For migrations between hosts running ESX/ESXi version 3.5 and later, vMotion and migrations of suspended and powered-off virtual machines are allowed.
  • During a migration with vMotion, if the swap file location specified on the destination host differs from the swap file location specified on the source host, the swap file is copied to the new location. This may result in slower migrations with vMotion. If the destination host cannot access the specified swap file location, it stores the swap file with the virtual machine configuration file.
For additional information about editing the configuration file of a virtual machine, see Tips for editing a .vmx file (1714).

For translated versions of this article, see:

See Also

This Article Replaces


Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.


  • 35 Ratings

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.

What can we do to improve this information? (4000 or fewer characters)

Please enter the Captcha code before clicking Submit.
  • 35 Ratings