What is swap space?
Swap space in any operating system is the amount of disk space reserved for moving inactive pages from RAM. Swap spaces are of two types dedicated swap or swap files in Linux OS. Here we will create a swap file for the Linux system.
We assume that the system does have not swap partition for this guide.
Check if your system already exists swap partition.
Open the terminal, and enter the following command to check.
Check free memory and disk.
If you have sufficient space in your hard-disk then let’s continue.
Step:1 Make swap off
Step 2: Resize the swapfile
Here let us increase it to 2GB (assuming the existing one has 1GB space as given in the article)
dd if=/dev/zero of=/var/swapfile bs=1024k count=2000
Step 3: Make swapfile usable
Step 4: Make swapon
Step 5: Change permission to 0600
chmod 0600 /var/swapfile
Step 6: Verify the swapfile
Step 7: Make swap file permanent
echo '/var/swapfile none swap sw 0 0' | tee -a /etc/fstab