The default size for the swap slice, as calculated during the installation, is based on the total amount of memory in the system. As system memory gets larger, the value of paging to swap diminishes, and, while it is possible to simply not configure a swap slice on a very large memory system, the swap slice actually provides utility even if the system never actually pages to it, due to the internal requirement to reserve "virtual swap" space.
On a small system, as a rough estimate, swap space should be twice the size of non-dedicated memory. Larger amounts of swap space must be allocated for systems with larger RAM. The following table shows reasonable allocations of swap space for systems of different sizes (assuming no memfs):
|Size of system||Size of swap space|
If you have memfs filesystems, sum the value of swapmax for all memfs filesystems, convert the result to bytes, and add it to the appropriate system size shown above to obtain the correct swap space size.
If you intend to allocate a sizable amount of system memory for use as dedicated memory, more swap will be allocated, during installation, than is necessary. However, you can resize the swap space to a more reasonable value, and allocate the freed space to other slices or filesystems, during installation by selecting the ``Customize filesystems and slices'' screen. Information on how to complete this task is in the Getting Started Guide. After installation, this can be done by following the process described in UNRESOLVED XREF-0.
For example, if you are adding 1GB of swap space to a system, increase SEGKMEM_BYTES by 4MB (or 0x400000). (Use /etc/conf/bin/idtune -g SEGKMEM_BYTES to obtain the old value.)
An attempt to use a swap slice larger the 512K blocks (or 256MB) can cause problems due to depletion of kernel virtual space. If you have not increased SEGKMEM_BYTES, as explained, then the attempt to add the swap space can fail. If the attempt succeeds, the result can be a poorly performing system, or even a system deadlock (hang).