Swap Management - II


Advanced Swap management
Actually its advantageous if we create swap partition separately if the server is not having any raw space left what we can do ? At any cost we have to increase the swap to improve the system productivity 
To come out of this situation there is one solution provided by Linux e.i we can create a swap file with in all ready existing and using partition if that partition is having sufficient free space

Step1:Switch off all the swap before any swap management

#swapoff -a

Step2:Determine what is the swap size we required(here i am taking 128MB) and execut the following command with count equal to 131072 (because 131072 is equal to 128M)

#dd if=/dev/zero of=/swapfile bs=1024 count=131072

Step3:Now set this swap file in order to use this file as swap

#mkswap /swapfile

Step4:Edit the /etc/fstab file to specify the swap file for perminient swap space

#vi /etc/fstab

/swapfile    swap    defaults    0 0

:wq

Step5:Update the kernel about the mount table changes

#mount -a

Step6:After managing the swap on the swap

#swapon -a

Step6:Check weather the swap space is updated or not by using following commands

#free -m   
#swapon -s 
#cat /proc/swaps
 

Removing swap:

Step1:Before doing any thing with swap first we have to switch of the swap

#swapoff -v /swapfile

Step2:Remove/comment the entry of swap from /etc/fstab file

#vi /etc/fstab

then save and exit

Step3:update the kernel about mount table changes

#mount -a

Step4:Remove the swapfile permanently 

#rm /swapfile

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Related Posts by Categories



    4 comments:

    Linux-guruP said...

    good article :)

    Hope u post more articles

    Surendra Kumar Chowdary said...

    thanks for the comment, Please let me know what you want to see more on this blog

    dpanupam said...

    Your blog is really useful. Web Designer

    Surendra Kumar Chowdary said...

    Hi Dpanupam,

    thanks for your comments please let me know which are other topics you want to see on this blog

    Surendra.

    Archive

    Translate this page

     

    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here