VMware ESXi – Swap files

Virtual machines running on an ESXi host uses a swap file (vSwap) for any memory that is not reserved.

VMware ESXi swap files are temporary files created by the hypervisor when the VM is powered on to store data that cannot fit in the physical memory (RAM) of a virtual machine. This swap file is used when the virtual machine is unable to allocate physical memory from the ESXi host. When the memory is overcommitted, the hypervisor moves the least used memory pages to the swap file and frees up memory for other processes. In larger environments this can increase the storage usage to provide multiple virtual machines with vSwap space.

Configuring memory reservation on the VM will change the size of the required swap file. An example:

  • VM – 4 GB – no memory reservation ==> 4 GB swap file
  • VM – 4 GB – 1 GB memory reservation ==> 3 GB swap file
  • VM – 4 GB – all guest memory reserved ==> 0 GB swap file

There is also a second swap file (50-150 MB) created with the prefix vmx that is the swap file for the overhead memory reserved for the VMX process. This can be disabled by configuring the advanced setting “schedule.swap.vmxSwapEnabled” to false

Swap files are by default stored at the same location as the VMs configuration file, but the swap file location can be configured:

The location of the virtual machine swap file affects vMotion compatibility in different ways depending on the version of ESXi running on the virtual machine’s host. For example, if the swap file location on the destination host differs from the swap file location on the source host, the swap file is copied to the new location, which can result in slower migrations with vMotion.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.