From Wiki-UX.info

Wiki-UX / Swap / How to configure swap on a file system
Jump to: navigation, search

How to configure swap on a file system

Abstract

This article explains how to use a file system instead of a whole disk or logical volume as a swap device. Using file systems for swap allocation creates a new directory on the file system named pagging.

Contents


Procedure

1. Check current swap configuration.

# swapinfo -tam
             Mb      Mb      Mb   PCT  START/      Mb
TYPE      AVAIL    USED    FREE  USED   LIMIT RESERVE  PRI  NAME
dev        4096       0    4096    0%       0       -    1  /dev/vg00/lvol2
reserve       -     270    -270
memory     1946     440    1506   23%
total      6042     710    5332   12%       -       0    -

2. Identifed a file system with enough space to contain the required swap.

# bdf
Filesystem          kbytes    used   avail %used Mounted on
/dev/vg00/lvol3    1048576  338792  704312   32% /
/dev/vg00/lvol1    1776056  119440 1479008    7% /stand
/dev/vg00/lvol8    6291456 1321288 4931424   21% /var
/dev/vg00/lvol7    6291456 2122744 4136152   34% /usr
/dev/vg00/lvol6     524288   35520  485080    7% /tmp
/dev/vg00/lvol5    6291456 3040272 3225840   49% /opt
/dev/vg00/lvol4    1048576   21184 1019376    2% /home
/dev/vg01/lvol1    2097152   17595 1949592    1% /swap2      <--- Swap file system

In this example the system there is 2 GB available on the /swap2 file system. This file system was created for this purpose. Any other mounted file system, including root (/), can be use to configure as file system swap if enough space is available.

3. Use the swapon command to allocate the additional swap space in the file system. Use the -m and -l options to allocate 1 GB off additional swap space.

# swapon -m 1024M -l 1024M -p 0 /swap2
 
# swapinfo -tam
             Mb      Mb      Mb   PCT  START/      Mb
TYPE      AVAIL    USED    FREE  USED   LIMIT RESERVE  PRI  NAME
dev        4096       0    4096    0%       0       -    1  /dev/vg00/lvol2
localfs    1024       0    1024    0%    1024       0    0  /swap2/paging
reserve       -     275    -275
memory     1946     453    1493   23%
total      7066     728    6338   10%       -       0    -

Note that the /swap2/paging directory was created below /swap2.

4. Add a new entry on /etc/fstab configuraiton file to enable the file system swap during system boot time.

# cat /etc/fstab
# System /etc/fstab file.  Static information about the file systems
# See fstab(4) and sam(1M) for further details on configuring devices.
/dev/vg00/lvol3 / vxfs delaylog 0 1
/dev/vg00/lvol1 /stand hfs defaults 0 1
/dev/vg00/lvol4 /home vxfs delaylog 0 2
/dev/vg00/lvol5 /opt vxfs delaylog 0 2
/dev/vg00/lvol6 /tmp vxfs delaylog 0 2
/dev/vg00/lvol7 /usr vxfs delaylog 0 2
/dev/vg00/lvol8 /var vxfs delaylog 0 2
/dev/vg01/lvol1 /swap2 vxfs delaylog 0 2
default /swap2 swapfs min=1024M,lim=1024M,pri=0 0 0
NOTE: File system based swap can be increased anytime without rebooting the system. Reduce the allowed space required a system reboot, except on HP-UX 11i v3 where the swapoff is available.


For example:

# bdf
Filesystem          kbytes    used   avail %used Mounted on
/dev/vg00/lvol3    1048576  341328  701792   33% /
/dev/vg00/lvol1    1776056  119696 1478752    7% /stand
/dev/vg00/lvol8    6291456 1382520 4870648   22% /var
/dev/vg00/lvol7    6291456 2125328 4133624   34% /usr
/dev/vg00/lvol6     524288   31872  488680    6% /tmp
/dev/vg00/lvol5    6291456 3041304 3224824   49% /opt
/dev/vg00/lvol4    1048576   21256 1019296    2% /home
/dev/vg00/swap2    4194304   18109 3915190    0% /swap2
 
# swapon -m 1024M -l 1024M -p 0 /swap2
 
# swapinfo
             Kb      Kb      Kb   PCT  START/      Kb
TYPE      AVAIL    USED    FREE  USED   LIMIT RESERVE  PRI  NAME
dev     4194304       0 4194304    0%       0       -    1  /dev/vg00/lvol2
localfs 1048576       0 1048576    0% 1048576       0    0  /swap2/paging
reserve       -  291644 -291644
memory  1992704  477556 1515148   24%
 
# swapon -m 1536M -l 1536M -p 0 /swap2
 
# swapinfo
             Kb      Kb      Kb   PCT  START/      Kb
TYPE      AVAIL    USED    FREE  USED   LIMIT RESERVE  PRI  NAME
dev     4194304       0 4194304    0%       0       -    1  /dev/vg00/lvol2
localfs 1572864       0 1572864    0% 1572864       0    0  /swap2/paging
reserve       -  289820 -289820
memory  1992704  481860 1510844   24%

Reference

HP-UX 11i v2

HP-UX 11i v3

Authors

This page was last modified on 22 July 2010, at 03:02. This page has been accessed 4,477 times.