|Skip Navigation Links|
|Exit Print View|
|System Administration Guide: Devices and File Systems Oracle Solaris 11 Express 11/10|
As system configurations change and new software packages are installed, you might need to add more swap space. The easiest way to add more swap space is to use the mkfile and swap commands to designate a part of an existing UFS or NFS file system as a supplementary swap area. These commands, described in the following sections, enable you to add more swap space without repartitioning a disk.
Alternative ways to add more swap space are to repartition an existing disk or to add another disk. For information on how to repartition a disk, see Chapter 10, Managing Disks (Overview).
You can create a swap file to be used in a UFS root file system. Swap files are currently not supported in a ZFS root environment. The following general steps are involved in creating a swap file:
Creating a swap file by using the mkfile command.
Activating the swap file by using the swap command.
Adding an entry for the swap file in the /etc/vfstab file so that the swap file is activated automatically when the system is booted.
The mkfile command creates a file that is suitable for use as either an NFS-mounted swap area or a local swap area. The sticky bit is set, and the file is filled with zeros. You can specify the size of the swap file in bytes (the default) or in KB, blocks, or MB by using the k, b, or m suffixes, respectively.
The following table shows the mkfile command options.
Table 21-2 Options to the mkfile Command
Note - Use the -n option only when you create an NFS swap file.
For more information, see How to Obtain Administrative Rights in System Administration Guide: Security Services.
You can create a swap file without root permissions. However, to avoid accidental overwriting, root should be the owner of the swap file.
# mkfile nnn[k|b|m] filename
The swap file of the size nnn (in KB, bytes, or MB) with the filename you specify is created.
# /usr/sbin/swap -a /path/filename
You must use the absolute path name to specify the swap file. The swap file is added and available until the file system is unmounted, the system is rebooted, or the swap file is removed. Keep in mind that you cannot unmount a file system while some process or program is swapping to the swap file.
/path/filename - - swap - no -
$ /usr/sbin/swap -l
Note - If a swap file does not get activated, make sure that the following service is running:
# svcs nfs/client STATE STIME FMRI enabled 14:14:34 svc:/network/nfs/client:default
Example 21-1 Creating a Swap File and Making It Available in a UFS Root Environment
The following examples shows how to create a 100-MB swap file called /files/swapfile.
# mkdir /files # mkfile 100m /files/swapfile # swap -a /files/swapfile # vi /etc/vfstab (An entry is added for the swap file): /files/swapfile - - swap - no - # swap -l swapfile dev swaplo blocks free /dev/dsk/c0t0d0s1 136,1 16 1638608 1600528 /files/swapfile - 16 204784 204784