Swap management




Swap management - I
Step1:First check what is the swap space the system is having and utilization of swap size

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

this will give output of swap statistics in Megabytes(m), if we want the output in Kilobytes then free -k

Step2:Before starting the Swap management we have to take precautions such as switch off all the swap and no user should be logged in  

#swapoff -a

Step3:Check in the system if there is any raw space in the system

#fdisk -l

Step4:If the system is having free space then create a partition which support swap(partition type 82) with required amount of free space

#fdisk /dev/hda

p                #press p to print the partition table
n                #press n for creating new partition
256M          #specify the amount of swap required
t                 #press t to change the partition type to 82 (because partition type 82 is well supported for swap)
8                 #enter the partition no on which u want to create swap(here i am creating on /dev/hda8 partition)
82               #specifying the partition type
p                 #press p to print the partition table and to just conform the /dev/hda8 partition type
w                #press w for writing the changes to partition table (if suppose if u have any problem or trouble just                                           press q to quit from fdisk utility without any problem)

Step5:update the partition table changes to kernel so that there is no need to restart the system/server

#partprob

Step6:Permanently mounting the partition details,in order to do this one we have to update the /etc/fstab file

#vi /etc/fstab

/dev/hda8    swap    swap    defaults    0 0

enter the above entires in to fstab file,save it and exit from editing /etc/fstab file

:wq

Step7:formatting/creating swap signature on the newly created partition

#mkswap /dev/hda8

Note:stpe6 and step7 are interchangeable.

Step8:update the mount table to kernel

#mount -a

Step9:now on the swap so that it can be available for use.

#swapon -a

Step10:check weather the swap is updated or not

#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 -a

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 partition used by swap

#fdisk /dev/hda8

d                #press d to delete the partition
8                #specify the partition no to be deleted 
w                #press w to write the changes to partition table and quit the fdisk utility

Step5:update the partition table changes to kernel with out rebooting the system/server

#partprobe

Step6:now on the swap 

#swapon -a

Step7:now check weather swap is updated properly or not

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

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



    0 comments:

    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