Contained WithinFind More DocumentationFeatured Support Resources |
Chapter 41 Configuring Additional Swap Space (Tasks)This chapter provides guidelines and step-by-step instructions for configuring additional swap space after the Solaris release is installed. This is a list of step-by-step instructions in this chapter. This is a list of the overview information in this chapter. About Swap SpaceSystem administrators should understand the features of the SunOS swap mechanism to determine the following:
Swap Space and Virtual MemoryThe Solaris software uses some disk slices for temporary storage rather than for file systems. These slices are called swap slices. Swap slices are used as virtual memory storage areas when the system does not have enough physical memory to handle current processes. The virtual memory system maps physical copies of files on disk to virtual addresses in memory. Physical memory pages that contain the data for these mappings can be backed by regular files in the file system, or by swap space. If the memory is backed by swap space it is referred to as anonymous memory because there is no identity assigned to the disk space that is backing the memory. The Solaris environment uses the concept of virtual swap space, a layer between anonymous memory pages and the physical storage (or disk-backed swap space) that actually back these pages. A system's virtual swap space is equal to the sum of all its physical (disk-backed) swap space plus a portion of the currently available physical memory. Virtual swap space has these advantages:
Swap Space and the TMPFS File SystemThe TMPFS file system is activated automatically in the Solaris environment by an entry in the /etc/vfstab file. The TMPFS file system stores files and their associated information in memory (in the /tmp directory) rather than on disk, which speeds access to those files. This feature results in a major performance enhancement for applications such as compilers and DBMS products that use /tmp heavily. The TMPFS file system allocates space in the /tmp directory from the system's swap resources. This feature means that as you use up space in the /tmp directory, you are also using up swap space. So if your applications use the /tmp directory heavily and you do not monitor swap space usage, your system could run out of swap space. Use the following if you want to use TMPFS but your swap resources are limited:
Swap Space as a Dump DeviceA dump device is usually disk space that is reserved to store system crash dump information. By default, a system's dump device is configured to be an appropriate swap partition. If possible, you should configure a alternate disk partition as a dedicated dump device instead to provide increased reliability for crash dumps and faster reboot time after a system failure. You can configure a dedicated dump device by using the dumpadm command. For more information, see “Managing System Crash Information (Tasks)” in System Administration Guide: Advanced Administration. If you are using a volume manager to manage your disks, such as Solaris Volume Manager, do not configure your dedicated dump device to be under the control of Solaris Volume Manager. You can keep your swap areas under Solaris Volume Manager's control, which is a recommended practice. However, for accessibility and performance reasons, configure another disk as a dedicated dump device outside of Solaris Volume Manager's control. How Do I Know If I Need More Swap Space?Use the swap -l command to determine if your system needs more swap space. For example, the following swap -l output shows that this system's swap space is almost entirely consumed or at 100% allocation.
When a system's swap space is at 100% allocation, an application's memory pages become temporarily locked. Application errors might not occur, but system performance will likely suffer. For information on adding more swap space to your system, see How to Create a Swap File and Make It Available. Swap-Related Error MessagesThese messages indicate that an application was trying to get more anonymous memory, and there was no swap space left to back it.
TMPFS-Related Error MessagesThe following message is displayed if a page could not be allocated when writing a file. This problem can occur when TMPFS tries to write more than it is allowed or if currently executed programs are using a lot of memory.
The following message means TMPFS ran out of physical memory while attempting to create a new file or directory.
For information on recovering from the TMPFS-related error messages, see TMPFS(7FS). How Swap Space Is AllocatedInitially, swap space is allocated as part of the Solaris installation process. If you use the installation program's automatic layout of disk slices and do not manually change the size of the swap slice, the Solaris installation program allocates a default swap area of 512 Mbytes. Starting in the Solaris 9 release, the installation program allocates swap space starting at the first available disk cylinder (typically cylinder 0). This placement provides maximum space for the root (/) file system during the default disk layout and enables the growth of the root (/) file system during an upgrade. For general guidelines on allocating swap space, see Planning for Swap Space. You can allocate additional swap space to the system by creating a swap file. For information about creating a swap file, see Adding More Swap Space. The /etc/vfstab FileAfter the system is installed, swap slices and swap files are listed in the /etc/vfstab file. They are activated by the /sbin/swapadd script when the system is booted. An entry for a swap device in the /etc/vfstab file contains the following:
The file system that contains a swap file must be mounted before the swap file is activated. So, in the /etc/vfstab file, make sure that the entry that mounts the file system comes before the entry that activates the swap file. Planning for Swap SpaceThe most important factors in determining swap space size are the requirements of the system's software applications. For example, large applications such as computer-aided-design simulators, database-management products, transaction monitors, and geologic analysis systems can consume as much as 200-1000 Mbytes of swap space. Consult your application vendor for swap space requirements for their applications. If you are unable to determine swap space requirements from your application vendor, use the following general guidelines based on your system type to allocate swap space:
In addition to the general guidelines, consider allocating swap or disk space for the following:
Monitoring Swap ResourcesThe /usr/sbin/swap command is used to manage swap areas. Two options, -l and -s, display information about swap resources. Use the swap -l command to identify a system's swap areas. Activated swap devices or files are listed under the swapfile column.
Use the swap -s command to monitor swap resources.
The used value plus the available value equals the total swap space on the system, which includes a portion of physical memory and swap devices (or files). You can use the amount of available and used swap space (in the swap -s output) as a way to monitor swap space usage over time. If a system's performance is good, use swap -s to see how much swap space is available. When the performance of a system slows down, check the amount of available swap space to see if it has decreased. Then you can identify what changes to the system might have caused swap space usage to increase. When using this command, keep in mind that the amount of physical memory available for swap usage changes dynamically as the kernel and user processes lock down and release physical memory. Note – The swap -l command displays swap space in 512-byte blocks and the swap -s command displays swap space in 1024-byte blocks. If you add up the blocks from swap -l and convert them to Kbytes, the result will be less than used + available (in the swap -s output) because swap -l does not include physical memory in its calculation of swap space. The output from the swap -s command is summarized in the following table. Table 41–1 Output of the swap -s Command
Adding More Swap SpaceAs 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 add another disk. For information on how to repartition a disk, see Chapter 31, Managing Disks (Overview). Creating a Swap FileThe following general steps are involved in creating a swap file:
The mkfile CommandThe mkfile command creates a file that is suitable for use as either an NFS-mounted 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 Kbytes, blocks, or Mbytes by using the k, b, or m suffixes, respectively. The following table shows the mkfile command options. Table 41–2 Options to the mkfile Command
Use the -n option only when you create an NFS swap file. How to Create a Swap File and Make It Available
Example—Creating a Swap File and Making It AvailableThe following examples shows how to create a 100–Mbyte swap file called /files/swapfile.
Removing a Swap File From UseIf you have unneeded swap space, you can remove it. How to Remove Unneeded Swap Space
Example—Removing Unneeded Swap SpaceThe following examples shows how to delete the /files/swapfile swap file.
|
|||||||||||||||||||||||||||||||||||||||||||