VMware Cloud Community
uvdevnull
Enthusiast
Enthusiast
Jump to solution

vswp file location

Changed Swap datastore in Host settings. Changed Swap file location in Guest to use location specified by Host. There is now a small 1 GB sysSwap-ds-###.swp file in the datastore I specified but still every time the Guest is powered on, a large vswp file gets created in the original location where the Guest has all its other files. This kinda defeats the purpose so I must be missing a step?

ESXi 6.7

0 Kudos
3 Solutions

Accepted Solutions
sunvmware1
Enthusiast
Enthusiast
Jump to solution

Hi,

For each powered-on virtual machine, a .vswp file is placed in the virtual machines directory on the datastore. This file is required by VMkernel to swap virtual machine memory to the disk in case of excessive overprovisioning. The swap file size can be calculated with the formula (.vswp File = Allocated Memory - Memory Reservation). As per default, the reservation is set to 0, so the .vswp file size is equal to the amount of virtual memory.

sunvmware1_0-1630810178454.png

Having the whole amount of memory from all virtual machines occupying the datastore wastes a lot of capacity. To get rid of the .vswp space, you have to reserve parts or all guest memory. If your virtual machine has 16GB and you reserve 50%, your .vswp file is only 8GB. If you reserve 100%, the file is still there but with a size of 0 bytes. The file will never disappear completely.

Please note that the swap file can only grow while the virtual machine is running. If you want to shrink the file (by increasing memory reservation) you have to power cycle the virtual machine.

sunvmware1_1-1630810209008.png

 

 

No memory reservation (default):

root@deore:/volumes/vol2/staging/Test_Bed# ls -al | grep vswp
-rw------- 1 nfs  nobody  3221225472 Dec 23 13:31 Test_Bed-ad493981.vswp
-rw------- 1 nfs  nobody   115343360 Dec 23 13:31 vmx-Test_Bed-2907257217-1.vswp

With memory reservation locked-in:

root@deore:/volumes/vol2/staging/Test_Bed# ls -al | grep vswp
-rw------- 1 nfs  nobody           0 Dec 23 13:38 Test_Bed-ad493981.vswp
-rw------- 1 nfs  nobody   115343360 Dec 23 13:38 vmx-Test_Bed-2907257217-1.vswp

 

View solution in original post

a_p_
Leadership
Leadership
Jump to solution

In order for the setting to take effect, you need to power cycle the VM. A guest OS reboot is not sufficient.

André

View solution in original post

sunvmware1
Enthusiast
Enthusiast
Jump to solution

@uvdevnull

To take effect you need to power cycle the VM and only guest OS reboot is not sufficient.

View solution in original post

0 Kudos
6 Replies
sunvmware1
Enthusiast
Enthusiast
Jump to solution

Hi,

For each powered-on virtual machine, a .vswp file is placed in the virtual machines directory on the datastore. This file is required by VMkernel to swap virtual machine memory to the disk in case of excessive overprovisioning. The swap file size can be calculated with the formula (.vswp File = Allocated Memory - Memory Reservation). As per default, the reservation is set to 0, so the .vswp file size is equal to the amount of virtual memory.

sunvmware1_0-1630810178454.png

Having the whole amount of memory from all virtual machines occupying the datastore wastes a lot of capacity. To get rid of the .vswp space, you have to reserve parts or all guest memory. If your virtual machine has 16GB and you reserve 50%, your .vswp file is only 8GB. If you reserve 100%, the file is still there but with a size of 0 bytes. The file will never disappear completely.

Please note that the swap file can only grow while the virtual machine is running. If you want to shrink the file (by increasing memory reservation) you have to power cycle the virtual machine.

sunvmware1_1-1630810209008.png

 

 

No memory reservation (default):

root@deore:/volumes/vol2/staging/Test_Bed# ls -al | grep vswp
-rw------- 1 nfs  nobody  3221225472 Dec 23 13:31 Test_Bed-ad493981.vswp
-rw------- 1 nfs  nobody   115343360 Dec 23 13:31 vmx-Test_Bed-2907257217-1.vswp

With memory reservation locked-in:

root@deore:/volumes/vol2/staging/Test_Bed# ls -al | grep vswp
-rw------- 1 nfs  nobody           0 Dec 23 13:38 Test_Bed-ad493981.vswp
-rw------- 1 nfs  nobody   115343360 Dec 23 13:38 vmx-Test_Bed-2907257217-1.vswp

 

uvdevnull
Enthusiast
Enthusiast
Jump to solution

@sunvmware1 

I reserved all memory and rebooted the guest but the vswp file remains large. Or should this be removed manually?

vswp.png

0 Kudos
a_p_
Leadership
Leadership
Jump to solution

In order for the setting to take effect, you need to power cycle the VM. A guest OS reboot is not sufficient.

André

sunvmware1
Enthusiast
Enthusiast
Jump to solution

@uvdevnull

To take effect you need to power cycle the VM and only guest OS reboot is not sufficient.

0 Kudos
uvdevnull
Enthusiast
Enthusiast
Jump to solution

 @a_p_  @sunvmware1 

Thanks guys, that's what was needed.

sunvmware1
Enthusiast
Enthusiast
Jump to solution

If the Answer is helpful, please click "Mark as Correct Answer", this can be beneficial to other community members.

0 Kudos