How to increase SWAP size in Centos



About Linux Swapping
Linux RAM is composed of chunks of memory called pages. To free up pages of RAM, a “linux swap” can occur and a page of memory is copied from the RAM to preconfigured space on the hard disk. Linux swaps allow a system to harness more memory than was originally physically available.
However, swapping does have disadvantages. Because hard disks have a much slower memory than RAM, server performance may slow down considerably. Additionally, swap thrashing can begin to take place if the system gets swamped from too many files being swapped in and out.
Check for Swap Space
You can check available swap space by using following command.

 

Now add a raw hard disk in your machine.
To check your raw hard disk use lsblk command. Make a partition sdb1. 

 

Note: - The partition type should be linux swap whose id is 82.

Now create a swap id with the following command
# mkswap /dev/sdb1
You will get a UID number after running the command just copy that UUID number and make entry in /etc/fstab file so that it will mount permanently.

 


Now whenever you need to increase your swap size you can use the below command
# swapon  /dev/sdb1
If you want to off the swap size then
# swapoff /dev/sdb1
Thanks for reading the post..

Comments