Contained WithinFind More DocumentationFeatured Support Resources | Descargar este libro en PDF (1386 KB)
Chapter 38 Configuring Additional Swap Space (Tasks)This is a list of the overview conceptual information and step-by-step instructions in this chapter. About Swap SpaceIt is important for administrators to understand the features of the SunOS swap mechanism in determining:
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 which 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 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 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 means that as you use up space in /tmp, you are also using up swap space. So if your applications use /tmp 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:
How Do I Know If I Need More Swap Space?This section lists several possible error messages displayed when you run out of swap space. 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 Messages
This message is displayed if a page could not be allocated when writing a file. This can occur when TMPFS tries to write more than it is allowed or if currently executed programs are using a lot of memory.
This message means TMPFS ran out of physical memory while attempting to create a new file or directory. See TMPFS(7FS) for information on recovering from the TMPFS-related error messages. 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 default swap slices as shown in the table below. Table 38-1 Default Swap Space Allocations
Additional swap space can also be added to the system by creating a swap file. See "Adding More Swap Space" for information about creating a swap file. The /etc/vfstab FileAfter the system is installed, swap slices and files are listed in the /etc/vfstab file and are activated by the /sbin/swapadd script when the system is booted. An entry for a swap device in the /etc/vfstab file contains:
Because the file system containing a swap file must be mounted before the swap file is activated, make sure that the entry that mounts the file system comes before the entry that activates the swap file in the /etc/vfstab 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 any application whose data files typically exceed 10-20 Mbytes in size. If you are unable to determine swap space requirements from the application vendor, use the following guidelines to allocate swap space:
Monitoring Swap ResourcesThe /usr/sbin/swap command is used to manage swap areas. Two options, -l and -s, are used to 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 plus available figures equals total swap space on the system, which includes a portion of physical memory and swap devices (or files). You can use the amount of swap space available and used (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 swap space available to see if it has decreased. Then you can identify what changes to the system might have caused swap space usage to increase. Keep in mind when using this command 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, it 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 table below. Table 38-2 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 below, 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. See Chapter 28, Disk Management (Overview) for information on how to repartition a disk. 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 either as an NFS-mounted or 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 kilobytes, blocks, or megabytes using the k, b, or m suffixes, respectively. The table below shows the options to the mkfile command. Table 38-3 Options to the mkfile Command
Use the -n option only when creating 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 24 Mbyte swap file called /files/swapfiles.
Removing a Swap File From UseIf the user no longer needs the extra swap space, you can remove it. How to Remove Extra Swap Space
Example--Removing Extra Swap SpaceThe following examples shows how to delete the /files/swapfile swap file.
|
|||||||||||||||||||||||||||||||||||||||