Adding a Swap File on Solaris

This is straight out of the man pages, but I had a hard time finding it the first time that I needed it. If you have a Solaris system that badly needs more swap but you don't have a free swap device available, you can create a file in the file system and add it as additional swap.

  1. Use mkfile to create a file suitable for a local swap area. For example, to create a 1GB swap file:

        /usr/sbin/mkfile 1024m /swap

    where /swap is the name of the file to be used as swap space. Units for the size can be kilobytes (k), blocks (b), or megabytes (m).

  2. Tell the system to start using the file as swap:

        /usr/sbin/swap -a /swap

    Use swap -l to verify that the swap file has been activated.

Last spun 2013-07-01 from thread modified 2013-01-04