Contents
Does a Linux VM need swap?
You don’t need the swap space, but there are a few points you didn’t mention that are worth bearing in mind. Some pages which are loaded when the system starts will never be touched again. It’s arguably better to leave them on disk rather than in ram, though any performance gain is probably tiny.
Why do we need swap space in Linux?
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM.
Why do we need swap memory?
Swap is used to give processes room, even when the physical RAM of the system is already used up. In a normal system configuration, when a system faces memory pressure, swap is used, and later when the memory pressure disappears and the system returns to normal operation, swap is no longer used.
How to enable swap space in Linux VM?
The waagent is already installed in the VM provisioned from a gallery image and one needs to simply edit its configuration file located at “/etc/waagent.conf” where the configuration looks like the following: Change the two lines shown above in the configuration file to enable swap, by setting as follows:
When do you not need to use swap space?
No Swap when available memory is low Unlike the case above, if you don’t have enough memory, swap will be used quite often and noticeably more during any memory requirement spikes. If you don’t have enough memory and no swap space, this will often cause failure to allocate memory for requests needing more memory pages.
Is it possible to run Linux without swap space?
It is possible to run a Linux system without a swap space, and the system will run well if you have a large amount of memory — but if you run out of physical memory then the system will crash, as it has nothing else it can do, so it is advisable to have a swap space, especially since disk space is relatively cheap. The key question is how much?
Why do virtual machines not need swap partitions?
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. 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.