Technical article 105921

How can I move swap space to a drive that already has filesystems on it in OpenServer 5.0.x?

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4

Written · Last revised

Problem

My system is configured to swap to the default swap device on the
root disk.  This is impacting my system performance.  I want to
move the swap area to a different drive that isn't as busy.  Is
there an easy way to do this?
NOTE:     The best solution is to prevent the system from swapping in the
          first place.  Memory access is on the order of 20-100 times faster
          than disk access, so any swapping is going to have a huge impact
          on system performance.  Overhead of the swapping mechanism makes
          the performance degradation even worse.

Solution

There is more than one way to accomplish this.  This article
addresses moving the swap space to a regular file on an existing
filesystem.  In most cases, this is perhaps the easiest way, in
that it requires no reconfiguring of the divvy tables for any of
the disks.  There are drawbacks to this method.
One drawback is that this doesn't free up the space currently used
by /dev/swap on the root hard disk.  Another is that swapping to a
file, instead of a raw device, introduces even more overhead because
all reads and writes must now go through the filesystem.

Swap space can be manipulated using the swap(ADM) command. If you want to add swap space using a file on a mounted filesystem, use the following commands:

>/u/swap
swap -a /u/swap 100000
where /u would be replaced by the mount point for the filesystem
and 100000 would be replaced by the number of 512 byte blocks to
be used.  This space will not actually be taken from the filesystem
until it is needed by the memory management subsystem.

To see the configured swap space, use the command swap -l. The output will now look something like this:

# swap -l
path               dev  swaplo blocks   free
/dev/swap          1,41      0 131064  98144
/u/swap           76,1       0 100000 100000
Note the /dev/swap will still be the primary swap device.  The
swap space just added will not be used until the primary has been
used up.  If your goal is to have all the swap activity on a
secondary disk, you need to delete the swap space allocated to
/dev/swap with the command:
swap -d /dev/swap
If this swap space is in use, this command may take a little while
to complete as the system will move the blocks allocated on
/dev/swap to /u/swap.  Once this is done, the system will no
longer use /dev/swap for swapping.
NOTE:     Deleting swap with the swap(ADM) command doesn't delete the
          swap division.  It only removes it from the list of devices
          that can be swapped to.  When the system is rebooted, the swap
          list will revert to the default.

To have the swap moved automatically at boot time, add these lines to /etc/rc2.d/P88USRDEFINE:

> /u/swap
swap -a /u/swap 100000 && swap -d /dev/swap || echo \
"Couldn't add swap device\\nSwapping to /dev/swap\\n" \
| mail -s "Swap add failed" root
The conditional statement prevents /dev/swap from being deleted
if the addition of the secondary swap fails.  It also causes mail
to be sent to root with notification of the problem.
NOTE:     The space in /u/swap will not be available as a dump device.  If
          you need to increase available swap space so there is room for a
          panic dump, you must use divvy to increase the size of the existing
          swap device or create a new dump device that is large enough to
          hold the entire contents of physical memory.  If /dev/swap is large
          enough to hold a panic dump, then you can continue to use it as the
          dump device.

From the Xinuos technical article database, record 105921. Reproduced with permission. The original is at www.sco.com/ta/105921, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.