Saturday, June 6, 2015

                     Increasing SWAP LVM in linux 

In conventional linux servers swap partition should be always recommended  to create as an LVM. This will give us the flexibility to increase the swap space as per our requirement ( mainly for increasing the system performance). But we have to follow some additional steps to increase the swap lvm along with general LVM extension procedure 

Existing swap details (here we have to extent the swap called /dev/mapper/swappolvg-swappollv to another 60GB)


[root@localhost01 ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/mapper/rootvg-swaplv               partition       8388604 0       -1
/dev/mapper/swappolvg-swappollv         partition       57066336       0       -2


1. first we have to off the swap space using below command 

 #swapoff -v /dev/swappolvg/swappollv

So after that if you check the swap details you can see only 1 swap is active 

[root@localhost01 ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/mapper/rootvg-swaplv               partition       8388604 0       -1

2. Here the extra disk is  added is showing as /dev/xvdo. So need to follow below steps to create a LVM partition for newly added swap space ( i am removing the output of normal lvm creation steps)

format the new disk 
#fdisk /dev/xvdo
...........................
create a physical disk 
#pvcreate /dev/xvdo1
................................
extent the volume group 
# vgextend swappolvg /dev/xvdo1
..............................
extent the logical volume 
#lvextend /dev/swappolvg/swappollv /dev/xvdo1
...............................

3. After all these steps now we have to format the swap volume 

#mkswap /dev/swappolvg/swappollv


4. Now we have to on the swap volume using below command 

#swapon -va

5. Now if we check the swap details we can see that swap in extended 

[root@localhost01 ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/mapper/rootvg-swaplv               partition       8388604 0       -1
/dev/mapper/swappolvg-swappollv         partition       117428220       0       -2











No comments:

Post a Comment