Learn how to add a secondary swap or extra swap in running the HPUX system without any downtime. It uses free space in root VG to mount as swap.
When the 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 the 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 up to 8.8GB of free space in root VG. We can use space from this 8.8GB for adding extra swap.
Read our Linux swap related articles :
Check the current swap configuration. Here you can see like default HPUX configuration, lvol2 is mounted as swap.
# /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 a new contiguous logical volume with no bad block relocation policy and size of your requirement. Let’s make an 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"
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf
Step 3
Start swap on this lvol. Add -f
argument to start forcefully if the 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. Now you can see new lvol is added in the swap.
# /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 -