How To Create Or Increase Swap Space In Linux
This freeing up of physical memory will be used for other applications. When the physical memory is available enough, the swap memory area will be brought back to the physical memory. The administrators ensure that sufficient swap space present in the system so that some free physical memory always available to the operating system.This article provides steps to create or increase swap space and also delete if you need.
Do I really need swap space?
Partition or file?
What is the recommended swap size?
Creating swap space
- Login as root.
- Create swap file in directory “/var” with name “swapfile”. At the shell, create the file and set root permissions as follows:
- Use “dd” command to fill the swap file with 1 GB size (as an example) as follows :
- Now setup the swap file:
- Enable the swap file:
- To check whether the new swap file was successfully created, either of the below commands can be used.
- Add below line to the “/etc/fstab” file so that next time when the system boots, it enables the newly created swap file: