Performing basic system monitoring and tuning

Changing swap space size

You might want to change the amount of swap space on your system because of performance considerations or hardware changes. For example, you might decide to distribute swap space across multiple disks, or increase the amount of swap space because additional RAM was added to your system.

NOTE: Use caution when changing swap size. The VTOC is a critical system resource. An error in this file can render the system unbootable or otherwise corrupt the contents of a filesystem.

Adding swap space

NOTE: An attempt to use a regular file larger than 512K blocks (or 256MB) as swap can result in a kernel hang due to the requirement on the filesystem to allocate a backing store map. A swap requirement larger than 256MB should be satisfied by a swap slice, not by a regular file. See the Getting Started Guide for instructions on using the ``Customize filesystems and slices screen'' to modify a swap slice during installation.

To add swap space on an already installed system:

  1. Log in as root.

  2. Use the dd(1M) command to create a file equivalent in size to the amount of swap space you are adding:
       dd if=/dev/null of=file oseek=num bs=blocksize
    where file is the full pathname of the new file, blocksize is the block size of the root file system, and num is chosen so that num multiplied by the blocksize equals the number of MBs of swap space desired. The file must be in the root filesystem (``/'').

    This example creates a 200MB file on the default vxfs root filesystem:

       dd if=/dev/null of=/outputfile oseek=200 bs=1024k

  3. Use a text editor to edit the /etc/swaptab file and add information for device_name, start_offset, and size:

    file 0 -

    The device_name is the name of the file you created using the dd command, the start_offset is ``0'', and the minus sign indicates that the entire file is to be used as the size of the new swap space.

  4. Reboot the system to make the new swap space available for use.

For example, the following sequence of commands configures 32MB of swap space:

   # dd if=/dev/null of=swapfile oseek=32 bs=1024k
   0=0 records in
   0=0 records out
   # ls -l swapfile
   -rw-r---r--     1 root      sys      33554432 Jul 18 11:58 swapfile
   # swap -a swapfile
   # swap -l
   path                     dev     swaplo  blocks   free
   /dev/swap                38,2         0  819312   819312
   swapfile                 38,513       0   65536    65536

See swaptab(4) for more information about the /etc/swaptab file and dd(1M) for information about the data dump command.

Reducing swap space

To reduce swap space on an already installed system:

  1. Log in as root.

  2. Obtain a copy of the current VTOC:

    prtvtoc -f vtoc-file raw-device

    where vtoc-file is any unique filename you choose.

  3. Edit vtoc-file and change the size of the swap slice.

    The swap slice is usually defined on slice 2, and the current size (in sectors) of swap space is listed under the column labeled SIZE.

  4. Use edvtoc to write the changed VTOC to disk:

    edvtoc -f vtoc-file raw-device

  5. Reboot the system to make the new swap space available for use.

In effect, you have divided one slice into two slices. Refer to prtvtoc(1M) and edvtoc(1M) for more information on those commands.

Next topic: Managing processors and processes
Previous topic: Determining swap usage

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 22 April 2004