Migrating virtual machine swap (.vswp) files from one datastore to another
search cancel

Migrating virtual machine swap (.vswp) files from one datastore to another

book

Article ID: 304593

calendar_today

Updated On: 02-18-2025

Products

VMware vSphere ESXi

Issue/Introduction

This article provides steps to migrate the .vswp files without having to power off the virtual machines.

  • By default, if the virtual machine swap files (.vswp) are stored in an ESXi host swapfile datastore. Storage vMotion does not move these files.
  • Storage vMotion fails to migrate the .vswp files.

Resolution

To migrate the .vswp file to the same location as the virtual machine:
  1. Ensure that a new datastore is available to all the ESXi hosts in the cluster.
  2. Configure the ESXi host to use the destination datastore for the .vswp files of their virtual machines. (To add the Swapfile location for all the hosts in a cluster, right-click the cluster, select Edit Settings, select Swapfile location, select Store the swap file in the datastore specified by the host.

    Note: At the host level, select configuration, and select the virtual machine Swapfile location link). For more information, see Enable Host-Local Swap for a DRS Cluster in the vSphere Resource Management.
  3. vMotion the virtual machines to another ESXi host in the cluster. This recreates the .vswp files on the destination datastore.
  4. Optionally, vMotion the Virtual Machines back to the original ESXi host.

Additional Information

To migrate .vswp file from a datastore containing all the .vswp files to each of the respective VM's working directories:

    1. Change cluster settings to Store swapfile in the same directory as the Virtual Machine.
    2. Confirm in each host's Configuration -> Virtual Machine Swapfile Location set to Virtual Machine directory.
    3. Right click the VM -> Power -> Shutdown guest (do not Reboot the guest or restart from within the Guest OS), and then power back on.
    4. Now the .vswp file is removed from the original vswp datastore and re-created in the VM's working directory.