How To Create Or Increase Swap Space In Linux
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: