Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Servers and Workstations: Managing Systems and Workgroups > Chapter 6 Administering a System: Managing Disks and Files

Managing Swap and Dump

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

This section explains how to manage your system’s swap space, including determining how much and what type of swap space the system needs, and how to add or remove swap space as the system’s needs change.

It also explains how to configure your dump area.

For additional information, see also:

Types of Swap Space

There are three types of swap space: device swap, file system swap, and pseudo-swap space. Each is used differently by the system and has its own advantages and disadvantages.

Device Swap

Swap space is initially allocated when you configure your disks. Device swap space occupies a logical volume or partition, which is typically reserved expressly for swapping purposes. This space may also be configured as a dump area; see “Configuring Dump ”.

Device swap can only be used locally; device swap cannot be accessed remotely by clients using NFS.

Device swap space is quickly accessed because the operating system can get to the logical volume or partition directly to perform large I/Os.

File System Swap

You can additionally use available space in a file system for swap space. Setting up such file system swap space allows for extra swap if there is occasional need for more than the allocated device swap space. It is used only when device swap space is insufficient.

When your system needs extra swap space, file system swap allows you to use existing file system space rather than reserving an entire dedicated logical volume or partition. However, because file system swap requires the system to perform a greater amount of processing and is usually slower than device swap, it should not be used as a permanent replacement for a sufficient amount of device swap space.

The file system used for swap can be either a local or a remote file system. Cluster clients can use remote file system swap for their swap needs. Swapping to a remote file system is slower than swapping to a local file system and is not encouraged if local device swap or local file system swap is available.

Pseudo-Swap

Pseudo-swap space allows for the use of system memory as a third type of swap space. That is, HP-UX swap space can also consist of up to seven-eighths (87.5%) of system memory capacity.

For example, a computer with one GB of system memory and one GB of device and file system swap, can run up to 1.87GB of processes. If any process attempts to grow or be created beyond this extended threshold, the process will fail.

When using pseudo-swap, since more processes can be created, the system load increases, causing more paging and deactivation activity.

By default, pseudo-swap space is configured to be available. If you do not wish to make use of it, you will need to reset the tunable system parameter, swapmem_on, to 0 (“off”).

Primary and Secondary Swap

Your system must have at least one device swap area available when it boots. This area is known as the primary swap area. (Primary swap is not mandatory if pseudo-swap is enabled, however, it is strongly recommended.) Primary swap, by default, is located on the same disk as the root file system. By default, the system’s kernel configuration file /stand/system contains the configuration information for primary swap.

Other swap may be used in addition to primary swap. Such swap is referred to as secondary swap. If you are using device swap as secondary swap, allocate such secondary swap to reside on a disk other than the root disk for better performance. File system swap is always secondary swap.

Designing Your Swap Space Allocation

When designing your swap space allocation:

  • Check how much swap space you currently have.

  • Estimate your swap space needs.

  • Adjust your system’s swap space parameters.

  • Review the recommended guidelines.

Checking How Much Swap Space You Currently Have

Available swap on a system consists of all swap space enabled as device and file system swap. To find how much swap space is presently available on your system and how much is being used, use SAM or run the command swapinfo.

The output of swapinfo tells you the type of swap by location, how much of it is available, how much is used, how much is free, and how much is reserved but not allocated. For more information, refer to swapinfo(1M).

Estimating Your Swap Space Needs

Your swap space must be large enough to hold all the processes that could be running at your system’s peak usage times. As a result of the larger physical memory limits of the 64-bit hardware platforms introduced at 11.0, you will need to significantly increase the amount of swap space for certain applications on these systems.

If your system performance is good, and, in particular, if you are not getting swap errors such as Out of Memory or those to the effect that a process was killed due to no swap space, then your system has adequate swap space.

Typically, unless the amount of physical memory on your system is extremely large, the minimum amount of swap space should equal the amount of physical memory on the system. In general, make swap space to be roughly two to four times your physical memory.

Swap space usage increases with system load. If you are adding (or removing) a large number of additional users or applications, you will need to re-evaluate your swap space needs.

NOTE: To get the total amount of swap space being used, run

swapinfo -ta

If the total percentage used is high, roughly 90% or greater, then you probably need to add more swap space.

Once you know or suspect that you will have to increase (or decrease) your swap space, you should estimate your swap space requirements. The following section describes one method.

You can estimate the amount of swap space you need by adding the space required by the applications you expect to run on your system to the amount of physical memory you have.

If you do not know the amount of physical memory on your system, you can get this information by running sam. From SAM’s main screen, select “Performance Monitors” and then “System Properties”. Finally, click on the Memory button. You will find an entry listing Physical Memory.

NOTE: If your HP-UX 10.x system is pre-10.20, you can get this information by checking the file /var/adm/syslog/syslog.log or /var/adm/syslog/OLDsyslog.log.

You also get this information from your console whenever your system is booted; look on the line beginning real mem =.

Divide any value of physical memory which is in KB by 1024 to obtain its value in MB.

Or, if your system currently has sufficient swap space, then you can increase swap space levels to accommodate new applications.

Use the following worksheet to estimate the size needed for your swap space. Remember, 1KB = 1024 bytes.

Local Swap Space Needs

For standalone (a server or otherwise) and client systems that will swap to local swap space either to a device or a file system, you can estimate your swap space needs as follows:

1. Enter the amount of the physical memory currently on the local machine. At a minimum, swap space should equal that amount. Enter the amount in KB.

                                                                                                      — — — —

2. Determine the swap space required by your largest application (look in the manual supplied with your application or check with the manufacturer; 1MB = 1,024KB = 10,248 bytes). If you will be running several applications concurrently, you should add their swap space requirements together.

                                                                                                      — — — —

TOTAL local swap space needed (in KB): sum of 1 and 2

                                                                                                      — — — —

Server Swap Space Needs

For a system that has local swap and also serves other systems with swap space, make a second estimation in addition to the one above.

1. Include the local swap space requirements for the server machine, based on the estimation from above.

                                                                                                      — — — —

2. Add up the total swap space you estimate each client requires. At a minimum, this number should equal the sum of physical memory for each client.

                                                                                                      — — — —

TOTAL server swap space (in KB): sum of 1 and 2

                                                                                                      — — — —

Adjusting Swap Space System Parameters

The default maximum amount of swap space you can configure, for both device swap and file system swap combined, is approximately 512MB. The tunable system parameter maxswapchunks controls this maximum.

The parameter maxswapchunks (default value of 256) limits the number of swap space chunks. The default size of each chunk of swap space is 2 MB.

For example, when the value of the parameter maxswapchunks is 256, the maximum configurable device swap space (maxswapchunks x swchunk x DEV_BSIZE) is:

256 x 2 MB = 512 MB

If you need to increase the limit of configurable swap space beyond the default, increase the value of the maxswapchunks operating system parameter either by using SAM (which has more information on tunable parameters) or reconfigure the kernel using HP-UX commands. The parameter swchunk is also tunable.

Guidelines for Setting Up Device Swap Areas

  • Interleave device swap areas for better performance.

    Two swap areas on different disks perform better than one swap area with the equivalent amount of space. This allows interleaved swapping which means the swap areas are written to concurrently, minimizing disk head movement, thus enhancing performance. (See “Guidelines for Assigning Swap Priority”.)

    When using LVM, you should set up secondary swap areas within logical volumes that are on different disks (physical volumes) using lvextend.

    If you have only one disk and need to increase swap space, then you should try to move the primary swap area to a larger region.

  • Similar-sized device swap areas work best.

    Device swap areas should have similar sizes for best performance. Otherwise, when all space in the smaller device swap area is used, only the larger swap area is available, making interleaving no longer possible.

  • The nswapdev tunable system parameter controls the maximum number of swap devices. SAM has more information on tunable parameters.

Guidelines for Setting Up File System Swap Areas

When you need more swap space and you have no devices available for additional device swap, or if you need to swap to a remote system, you can dynamically add file system swap to your system. Use the following guidelines:

  • Interleave file system swap areas for best performance.

    The use of interleaving on separate disks is described under “Guidelines for Setting Up Device Swap Areas ”.

  • To keep good system performance, avoid using heavily used file systems such as the root (/) for file system swap.

    Use the bdf command to check file systems for available space.

  • Use SAM or the swapinfo command to show information about file systems for which swap might be already enabled.

Guidelines for Assigning Swap Priority

When you add swap areas, you can assign a priority to each. Priorities range from 0 (the highest) to 10 (the lowest). The system uses the swap areas with higher priority first. The system gives device swap priority over file system swap when each has the same priority. Here are the guidelines you should use:

  • Given multiple swap devices with identical performance, assign each an identical priority. By so doing, you will allow the system to use each of them on an interleaved basis which enhances performance.

  • Assign higher priorities to the swap areas that have faster performance and lower priorities to areas that are slower.

  • Give device swap areas priority over file system swap areas.

  • Give lower use file systems priority over higher use file systems.

The primary swap area has priority 1. Device and file system swap areas set dynamically default to a priority of 1 if no priority is specified.

Adding, Modifying, or Removing File System Swap

At times when the designated device swap is insufficient, you can configure to allow a process to use an existing file system for swapping. When you enable a file system for swap, the operating system can swap to unused portions of the file system as needed. Unless you pre-allocate the swap space using the min option of the swapon command, file system swap which has not been recently used will be freed back to the file system when it needs the space.

Several file systems can be used for file system swap. The tunable system parameter nswapfs determines the maximum number of file systems you can enable for swap. You can dynamically create file system swap using either SAM or the swapon command. As with device swap, you cannot modify or remove file system swap without rebooting, although you can change options within /etc/fstab file without rebooting as long as they don’t conflict with previous requests.

If you use swapon to add file system swap, follow these steps:

  1. Choose a file system for swap space use. Be sure to consult “Guidelines for Setting Up File System Swap Areas ”.

  2. Determine the mount point directory (or the root directory) of the file system and specify its absolute path name on the command line for swapon.

  3. Examine the swapon command options (see swapon(1M)). The options allow you to customize how your file system swap will work.

  4. To verify that you have enabled your new file system, run the command swapinfo. You should see a line that begins fs, corresponding with the mount point you specified. This indicates that your dynamic file system swap space is now available.

  5. Add your file system swap to the /etc/fstab file if you want the new file system swap to be enabled when you boot your system. See fstab(4) for more information.

Once file system swap has been enabled, you can remove it either by using SAM or by following these steps:

  1. If you used SAM to add file system swap or manually added a swapfs type entry for this file system in /etc/fstab, then edit the /etc/fstab file to remove the entry for the specific file system swap area you want to remove.

  2. Reboot your system by running shutdown -r.

To modify a file system swap, you first remove it and then re-add the changed swap using the five steps shown above.

NOTE: If you have an entry in /etc/fstab defining the swap, but the swap has not been enabled using SAM or swapon, then you can just remove the entry either with SAM or by editing /etc/fstab. In this case, no reboot is necessary.

Configuring Primary and Secondary Swap

You can configure primary swap through the kernel configuration file, using either HP-UX commands or SAM.

You can also do the following to manage your primary swap space:

  • Increase primary swap.

    If you are using logical volumes, you may want to first attempt to extend the disk space allocated for the primary swap logical volume using the lvextend command or SAM. However, you will only succeed if disk space (physical extents) contiguous with the existing swap space is still available, which is unlikely. You must reboot the system for the changes to take effect.

    If contiguous disk space is not available, you will need to create a new contiguous logical volume for primary swap within the root volume group, the volume group that contains the root logical volume. You do not need to designate a specific disk. For example:

    lvcreate -C y -L 48 -r n -n pswap /dev/vgroot

    After creating a logical volume that will be used as primary swap, you will need to use lvlnboot(1M):

    lvlnboot -s /dev/vgroot/pswap
  • Reduce primary swap.

    If you are using logical volumes, you can do this by reducing the size or number of logical volumes used for primary swap. If you are not using logical volumes, you can discontinue the use of a disk section for primary swap. Reducing primary swap cannot be done dynamically; you must reboot the system for reduced primary device swap changes to take effect.

NOTE: If the location of your primary swap device has been specified in the system configuration file, then if it is changed or removed from this file, you must regenerate the kernel and reboot. (The default system configuration file is /stand/system; see config(1M) for more information).

If the primary swap device is not specified in the configuration file and this file does not include swap default, then the primary swap device must be the first device specified as swap in /etc/fstab. By listing swap devices in /etc/fstab, the swap devices will automatically be enabled when the system is rebooted. In this case, if you change or remove the first swap device specified from /etc/fstab, the kernel does not need to be reconfigured.

File system swap is always secondary swap. Use SAM to configure file system swap and thereby set up the optional secondary swap.

Configuring Dump

NOTE: This section gives general information on configuring disk space for dump. For a detailed discussion of system crash dumps and how to configure them, see “Abnormal System Shutdowns”.

A dump area is disk space used to write an image of the core memory after a system crash. The analysis of a core dump may be useful in troubleshooting and restoring the system to working order.

By default, the primary swap device also serves as a dump area when no other dump area is specifically designated. Although you are not required to retain primary swap as your dump area, doing so will conserve disk space. You can configure a different or multiple dump devices on your system. To do this, you will need to create a logical volume (or disk section) as a dump device. This device can also be used, if you wish, for swap.

With the 11.0 release, dump configuration allows for not only selecting which devices are to be used to store a crash dump, as in prior releases, but also, how much if any of the dump you wish to retain. Dumps no longer need to contain the entire contents of physical memory. With expanded physical memory limits, you may wish to dump only those classes of physical memory which you will use in a crash dump analysis.

Further, you now have an additional way to configure dump devices: In addition to reconfiguring the kernel, at 11.0, you can also do dump configuration at runtime using the crashconf(1M) command without the need to reboot the system.

You can use either of two ways to configure which classes of memory should be included in a dump. crashconf options can be used, or this information can be configured using the tunable parameters alwaysdump or dontdump when you reconfigure the kernel.

You can use SAM to add, remove, or modify dump devices, and to configure how much of the dump you wish to retain. For more information, see SAM’s online help.

How Much Disk Space Should Be Used for Dump?

The amount of disk space made available for core dumps should accommodate your system’s physical (core) memory. As a result of the larger physical memory limits of the 64-bit hardware platforms introduced at 11.0, you may need to significantly increase the amount of disk space for dump on these systems. (If you need to determine the amount of physical memory on your system, see “Estimating Your Swap Space Needs ”.)

Because the physical memory on your system may exceed the space available in the primary swap area, you may wish to configure additional disk space for the full core memory image. Otherwise, only a partial core image will be saved which may not be sufficient for analyzing problems.

Configuring Dump Areas Using HP-UX Commands

If you do not use SAM to configure your dump areas, you should follow the guidelines below:

Although dump areas can be configured within disk sections, it is preferable to use logical volumes.

A dump logical volume can exist only within the root volume group, that is, the volume group that contains the root logical volume.

To create a dump logical volume, you first use the lvcreate command. You must set a contiguous allocation policy using the -C y option and specify no bad block relocation using -r n. See lvcreate(1M) for more information.

When configuring a logical volume as a dump device, you must next use lvlnboot(1M) with the -d option to update the BDRA (Boot Data Reserved Area). The BDRA maintains the information that the kernel requires about each bootable disk within the root volume group.

Suppose, for example, you have created a logical volume /dev/vg00/lvol2 for use as a dump area.

To update the boot information, enter:

lvlnboot -d lvol2 /dev/vg00

It is possible to use any secondary swap logical volume as a dump area as well, provided the swap area is in the root volume group.

To discontinue the use of a currently configured logical volume as a dump device, you use lvrmboot(1M) also with the -d option.

CAUTION: To prevent possible file corruption, a dump logical volume (or a swap logical volume used for dump) must lie within the first two GB on the physical volume. The lvlnboot command will not allow a dump logical volume to be configured that exceeds two GB (but it will allow such a swap logical volume to be so configured).

Before the above changes to the BDRA take effect, you must either add (in the case of lvlnboot) or remove (in the case of lvrmboot) the following line within the system configuration file (/stand/system by default) and then reconfigure the kernel:

dump lvol

For more information on the system configuration file, see config(1M).

After reconfiguring the kernel, you must reboot the system.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997-2006 Hewlett-Packard Development Company, L.P.