[ Team LiB ] Previous Section Next Section

Configuring Additional Swap Space (mkfile, swap)

To create and add additional swap space without reformatting a disk, you first create a swap file with the mkfile command. You can specify the size of the swap file in kilobytes (the default) or in blocks or megabytes by using the b and m suffixes, respectively. The swap file can either be on a local disk or be NFS-mounted. You then add the swap space with the swap command.

To list available swap files, type swap -l and press Return. A list of available swap files is displayed. The swap command replaces the SunOS 4.x swapon command.


drusilla% swap -l
swapfile             dev  swaplo blocks   free
swapfs                -        0  94520  93512
/dev/dsk/c0t3d0s1   32,25      8  65512  45048
drusilla%

Use the following steps to create a swap file.

  1. Become superuser. You can create a swap file without root permissions, but it is a good idea to have root be the owner of the swap file so that other processes cannot access it.

  2. Type mkfile nnn[k|b|m] file-name and press Return. The letter following the number you specify indicates kilobytes, blocks, or megabytes. The swap file of the size and file name you specify is created. The following example creates a 1-Mbyte swap file named SWAP.


oak% su
Password:
# mkfile 1m /files1/SWAP
#

Use the following steps to add the swap file.

  1. Become superuser.

  2. Type swap -a path-name and press Return. You must use the absolute path name to specify the swap file. The swap file is added and becomes available.

  3. Type swap -l to verify that the swap file is added.


# swap -a /files1/SWAP
# swap -l
swapfile               dev  swaplo blocks   free
swapfs                  -        0  94520  93512

/dev/dsk/c0t3d0s1     32,25      8  65512  45048

/files1/SWAP  -  8     2040   2040
#

Use the following steps to remove a specified swap file from use.

  1. Become superuser.

  2. Type swap -d path-name and press Return. When the swap file is no longer in use, it is removed from the list so that it is no longer available for swapping. The file itself is not deleted.


oak% su
Password:
# swap -d /files1/SWAP
# swap -l
swapfile              dev  swaplo
blocks   free
swapfs                 -        0
94520  93512

/dev/dsk/c0t3d0s1    32,25      8
65512  45048
# ls -l /files1/SWAP
-rw-------   1 root   root      1048576 Jan 31 13:56 SWAP
#

When you create additional swap space, if you want the swap space to remain available when the system is rebooted, you must add the entry to the /etc/vfstab file. Use the following steps to add a swap file entry to the /etc/vfstab file.

  1. Become superuser.

  2. Edit the /etc/vfstab file and add the following line. Be sure the line follows the entry for the partition in which the swap file was created.


path-name - - swap - no -

The next time the system is rebooted, the swap file is added automatically.

The following example adds the swap file /files1/SWAP to the /etc/vfstab file after the entry that mounts the file system /files1.


/files1/SWAP - - swap - no -


    [ Team LiB ] Previous Section Next Section