What is Swap
Swap is used to extend the available physical memory. It is possible to use more memory than physical RAM available.
Linux uses a page called “Least Recently Used” (LRU) to select pages that might be moved from memory to disk. Therefore, running applications have more memory available and caching works more smoothly.
Swap was being used as a saftey mechanism by the memory managment system of Kernel before version 2.4.10.
If the system has no swap, application gets the maximum allowed memory. All caches are freed and thus all other running applications are slowed. After a few minutes, the kernel’s out-of-memory kill mechanism activates and kills the process.
Adding A Swap File Manually In SUSE Linux
- Create an empty file in your system. For example, if you want to add a swap file with 128 MB swap at
/var/lib/swap/swapfile, use the commands:
mkdir -p /var/lib/swap dd if=/dev/zero of=/var/lib/swap/swapfile bs=1M count=128
- Initialize this swap file with the command
- Activate the swap with below command
- Check the current available swap spaces with the command below:
- To enable this swap file permanently, add the following line to
/var/lib/swap/swapfile swap swap defaults 0 0