How to create swap in Linux
A swap file or swap space is a space on a hard disk used as the virtual memory extension of a computer's real memory (RAM). Having a swap file allows your computer's operating system to pretend that you have more RAM than you actually do.
This article explains the detailed steps to create swap file in Linux.
Step1: Create swap file of desired size using dd command.
#dd if=/dev/zero of=/swap bs=1G count=4
Where "bs" is the block size and "count" is the number of blocks.
Step2: Correct the permissions of swap file.
#chmod 600 /swap
Step3: Create swap space
#mkswap /swap
Step4:Make the swap space availale
#swapon /swap
Step5: Verify the newly created swap space
#swapon -s
Step6: Add the swap in '/etc/fstab' and make it permanent.
/swapfile swap swap defaults 0 0
Thats all……