SolarisAddSwap

How to add swap under Solaris

Overview of the "swap" command

The table below could be useful:

Option of the swap command Displays/Does
swap -sSummary of the system swap information
swap -lLonger listing of system swap information
swap -aAdd swap (see below)
swap -dDeletes swap

How to add a swap file

(Please see the link below to add swap partitions)

Short version:

mkfile 1000m /path/to/swap/file
swap -a /path/to/swap/file

Then, edit /etc/vfstab

Longer version:

Status of the system BEFORE adding an extra swap file:

andre@galactus$ df -k /u01
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/md/dsk/d8       20655529 1781618 18667356     9%    /u01

andre@galactus$ swap -l
swapfile             dev  swaplo blocks   free
/dev/dsk/c1t0d0s1   118,1      16 1058288 1058288
/dev/dsk/c1t1d0s3   118,11     16 8395184 8395184

Creating the swap file (please note the mkfile -v 3g command below):

root@galactus$ mkfile -v 3g /u01/swap_file
/u01/swap_file 3221225472 bytes

root@galactus$ ls -alF /u01
-rw------T   1 root     other    3221225472 Jun 14 15:44 swap_file

root@galactus$ df -k /u01
Filesystem           1024-blocks        Used   Available Capacity  Mounted on
/dev/md/dsk/d8          20655529     3560770    16888204    18%    /u01

Adding the swap file to the system:

root@galactus$ swap -a /u01/swap_file

root@galactus$ swap -l
swapfile             dev  swaplo blocks   free
/dev/dsk/c1t0d0s1   118,1      16 1058288 1058288
/dev/dsk/c1t1d0s3   118,11     16 8395184 8395184
/u01/swap_file        -       16 6291440 6291440

The /etc/vfstab file was then edited, and the following line added to it:

/u01/swap_file - - swap - no -

That's All Folks!

See Also: