JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
System Administration Guide: Devices and File Systems     Oracle Solaris 10 8/11 Information Library
search filter icon
search icon

Document Information

About This Book

1.  Managing Removable Media (Overview)

2.  Managing Removable Media (Tasks)

3.  Accessing Removable Media (Tasks)

4.  Writing CDs and DVDs (Tasks)

5.  Managing Devices (Overview/Tasks)

6.  Dynamically Configuring Devices (Tasks)

7.  Using USB Devices (Overview)

8.  Using USB Devices (Tasks)

9.  Using InfiniBand Devices (Overview/Tasks)

10.  Managing Disks (Overview)

11.  Administering Disks (Tasks)

12.  SPARC: Setting Up Disks (Tasks)

13.  x86: Setting Up Disks (Tasks)

14.  Configuring Oracle Solaris iSCSI Targets and Initiators (Tasks)

15.  The format Utility (Reference)

16.  Managing File Systems (Overview)

17.  Creating and Mounting File Systems (Tasks)

18.  Using The CacheFS File System (Tasks)

19.  Configuring Additional Swap Space (Tasks)

About Swap Space

Swap Space and Virtual Memory

Swap Space and the TMPFS File System

Swap Space as a Dump Device

Swap Space and Dynamic Reconfiguration

Configuring Swap Space in a SAN Environment

How Do I Know If I Need More Swap Space?

Swap-Related Error Messages

TMPFS-Related Error Messages

How Swap Space Is Allocated

Swap Areas and the /etc/vfstab File

Planning for Swap Space

Allocating Swap Space for UFS-Based Systems

Allocating Swap Space for ZFS-Based Systems

Monitoring Swap Resources

Adding More Swap Space

Creating a Swap File in a UFS Root Environment

mkfile Command

How to Create a Swap File and Make It Available in UFS Root Environment

Adding or Changing Swap Space in an Oracle Solaris ZFS Root Environment

How to Add Swap Space in an Oracle Solaris ZFS Root Environment

Removing a Swap File From Use

How to Remove Unneeded Swap Space in UFS Root Environment

How to Remove a Swap Volume in a ZFS Root Environment

20.  Checking UFS File System Consistency (Tasks)

21.  UFS File System (Reference)

22.  Backing Up and Restoring UFS File Systems (Overview)

23.  Backing Up UFS Files and File Systems (Tasks)

24.  Using UFS Snapshots (Tasks)

25.  Restoring UFS Files and File Systems (Tasks)

26.  UFS Backup and Restore Commands (Reference)

27.  Copying Files and File Systems (Tasks)

28.  Managing Tape Drives (Tasks)


Adding More Swap Space

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).

Creating a Swap File in a UFS Root Environment

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:

mkfile Command

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 19-4 Options to the mkfile Command

Creates an empty file. The size is noted. However, the disk blocks are not allocated until data is written to them.
Reports the names and sizes of created files.

Note - Use the -n option only when you create an NFS swap file.

How to Create a Swap File and Make It Available in UFS Root Environment

  1. Become superuser or assume an equivalent role.

    You can create a swap file without root permissions. However, to avoid accidental overwriting, root should be the owner of the swap file.

  2. Create a directory for the swap file, if needed.
  3. Create 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.

  4. Activate the swap file.
    # /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.

  5. Add an entry for the swap file to the /etc/vfstab file that specifies the full path name of the file, and designates swap as the file system type.
    /path/filename   -      -       swap     -     no     -
  6. Verify that the swap file is added.
    $ /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 19-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