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
without rebooting as long as they don't conflict with previous requests.
If you use swapon
to add file system swap, follow these steps:
Choose a file system for swap space use. Be sure to consult
"Guidelines for Setting Up File System Swap Areas" earlier in the
chapter.
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.
Examine the swapon
command options (see swapon(1M)). The options
allow you to customize how your file system swap will work.
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.
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:
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.
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. |
 |
 |  |
 |