Linux VM Swap Partition – Should VMware/ESX Have One?

linuxvmware-esxvmware-esxiwindows

On a VMware ESX setup what is the difference of these options?:

  • a Linux VM with 1GB RAM and 1GB swap partition and the VM uses 1.5 GB ram
  • a Linux VM with 1GB RAM and no swap partition and the VM uses 1.5 GB ram

I mean, in both cases swap is being used;

  • in the first swap is done to the linux swap partition
  • in the second case, VMware will swap 512MB to the VMware storage pool.

So are there any point in giving Linux VM's a swap partition?

Best Answer

Ignoring the fact that people are dealing with OS specific reasons I have two reasons why it's a bad idea to not run with a swap partition/file.

  1. If you have 1.5 GB of RAM allocated to a VM with no space file/partition and it wants to use 1.5 GB + 1 MB it will report an out of memory error. With the swap space it will be able to swap data out of active memory and onto the disk.
  2. The guest OS does a much better job of memory management than the host. This is why technology like memory ballooning exists because the Host can make educated guesses on what memory isn't needed right now but the guest knows at a much more intelligent level (this keeps OS memory from being swapped out which could kill your performance).