By default, a swap file is created when a virtual machine is powered ON under a ESXi host. Swap files normally are stored in the same location as in the VM’s configuration file, it could be a VMFS datastore or a vSAN datastore. Swap file location can give a big leap to the VM performance provided it is configured appropriately. If the host disk array is slow and is running a bunch of virtual machines coherently could lead to a serious performance degradation, especially when they are all swapping.
Hence it would be best advised to have a dedicated data store whereby the swap files are stored in an alternate location to increase the performance of the Virtual machines.
Swap file location of a VM can be changed when you observe the following over a period,
* Guest operating system failure
* Stop errors
* Read-only file system
* VM lag during resource intensive operations-high I/O
Steps to edit the virtual machine swap file location in ESX/ESXi 5.0
- Connect to the Vsphere client.
- Click the Configuration tab for ESXi/ESX host and then Click "Virtual Machine Swapfile
Location" and finally click Edit.
- Clicking edit will let you specify the datastore where you would want to store the virtual machine
- Virtual machines are to be restarted to complete the action
- Verify if the swap file is now created under the new location after reboot.
Steps to edit the swap file location for a sing virtual machine in ESX/ESXi host 5.0
- Turn off the Virtual machine.
- Unregister the virtual machine and Remove from Inventory.
- Connect to the host via SSH client
- Change the directory to the folder where the virtual machine resides: "cd
- Append this line "sched.swap.dir = /vmfs/volumes/datastore/" in the virtual machine’s
file using a text editor.
- Re-register the virtual macine
During VM migration, if the swap file location is default or a customer one in the destination host which differs from the swap file location defined in the source host, the swap file will be copied to the new location resulting in slower migrations with vMotion.
Here is a related post you maybe interested in: Steps to be taken when a VM goes in Read-only mode