Thursday, October 6, 2016

Adding extra or secondary swap in HPUX

Freeimages When system runs low on memory and swap continuously, its time to troubleshoot. Even after troubleshooting and all available ... thumbnail 1 summary
Freeimages
When system runs low on memory and swap continuously, its time to troubleshoot. Even after troubleshooting and all available app/OS tuning you are still running out of memory then you can try
adding extra swap before you think of adding RAM to server which involves cost/resources of parent machine.

Step 1.

For adding extra swap check how much space you have available in root volume group vg00. Use vgdisplay command to get free PE and PE size numbers.


# /usr/sbin/vgdisplay vg00
--- Volume groups ---
VG Name                     /dev/vg00
VG Write Access             read/write
VG Status                   available
Max LV                      255
Cur LV                      9
Open LV                     9
Max PV                      16
Cur PV                      2
Act PV                      2
Max PE per PV               4384
VGDA                        4
PE Size (Mbytes)            16
Total PE                    6544
Alloc PE                    5978
Free PE                     566
Total PVG                   0
Total Spare PVs             0
Total Spare PVs in use      0


Here we have 566 free PE with 16MB size of each. This sums upto 8.8GB of free space in root vg. We can use space from this 8.8GB for adding extra swap.

Check current swap configuration


# /usr/sbin/swapinfo -tam
             Mb      Mb      Mb   PCT  START/      Mb
TYPE      AVAIL    USED    FREE  USED   LIMIT RESERVE  PRI  NAME
dev       43008       0   43008    0%       0       -    1  /dev/vg00/lvol2
reserve       -    1963   -1963
memory    40861    9261   31600   23%
total     83869   11224   72645   13%       -       0    -


Step 2.

Create new contiguous logical volume with no bad block relocation policy and size of your requirement. Lets make a LV of 2GB. 


# lvcreate -L 2048 -C y -r n /dev/vg00
Logical volume "/dev/vg00/lvol10" has been successfully created with character device "/dev/vg00/rlvol10"


Step 3.

Start swap on this lvol. Add -f argument to start forcefully if below command fails.

# swapon -p 1 /dev/vg00/lvol10


Step 4.

Edit /etc/fstab to mount this LV as swap on every boot. Add below entry :


/dev/vg00/lvol10 ... swap pri=1 0 1


Step 5.

Check again swap size.


# /usr/sbin/swapinfo -tam
             Mb      Mb      Mb   PCT  START/      Mb
TYPE      AVAIL    USED    FREE  USED   LIMIT RESERVE  PRI  NAME
dev       43008       0   43008    0%       0       -    1  /dev/vg00/lvol2
dev        2048       0    2048    0%       0       -    2  /dev/vg00/lvol10
reserve       -    1963   -1963
memory    40861    9261   31600   23%
total     85917   11224   74693   13%       -       0    -





No comments

Post a Comment

Any thoughts?