Swap Space

Swap space:-

swap-space

Swap space is used to support or help the RAM. It  acts as Physical memory (RAM). It is like a virtual Physical memory (RAM) . Swap space is located on the hard disk. It is used to increase the overall system’s performance. Swap space needs a dedicated swap partition (82).

If the system physical memory (ram) is full then the inactive pages in ram are moved to the swap space, through this we can improve the system’s performance.

If we decide to transfer bulk data,its a lengthy process. So, swap space comes into effect.

Calculating swap space:-

If ram < 2 or ram = 2
Swap space = ram * 2
Else
Swap space = ram + 2
Example:-
2GB ram = 4GB swap space
3GB ram = 5GB swap space

Basically swap space speed is slow compared to ram. Because disks are much slower than RAM, this can lead to slower response time for system process and applications. In this case we can use swappiness parameter.

Swappiness:-

The swappiness parameter is used to control the kernel to move process from physical memory(ram) to swap space.

  1. Swappiness value between 0 to 100.
  2. Swappiness=0 tells the kernel to avoid swapping processes out of physical memory for as long as possible.
  3. Swappiness=100 tells the kernel to aggressively move process from physical memory to swap space.
  4. Default value of swappiness=60

To check the swappiness value
# cat /proc/sys/vm/swappiness

To change the swappiness value
# vim /etc/sysctl.conf
Edit
vm.swappiness=40
save and reboot the system.

System performance  = 1/swappiness

Handle swap partition:-

Check swap space details and ram details:-
# free -m

Check swap partition details:-
# swapon -s

Stop particular swap partition:-
# swapoff /dev/sda3

Stop all swap partition:-
# swapoff -a

Start particular swap partition:-
# swapon /dev/sda/3

Start all swap partition:-
# swapon -a

Create new swap partition:-

Create new partition
Change the linux partition type to ” 82 ” swap type.

Make swap partition:-
# mkswap /dev/sda3

Enable swap partition:-
# swapon /dev/sda3
# swapon -a

Check swap partion enabled:-
# swapon -s

Permanent mount:-
# vim /etc/fstab
add this line
/dev/sda3    swap    swap    defaults    0 0

 Add swap space:-
Same as above steps.

 

 

==========================> Blass <==========================




Leave a Reply

Your email address will not be published. Required fields are marked *