TMPFS-Related Error Messages
The 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.
directory: File system full, swap space limit exceeded |
The following message means TMPFS ran out of physical memory while attempting to create a new file or directory.
directory: File system full, memory allocation failed |
For information on recovering from the TMPFS-related error messages, see TMPFS(7FS).
How Swap Space Is Allocated
Initially, 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. 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 File
After 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 full path name of the swap slice or swap file
File system type of swap
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 Space
The 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:
System Type | Swap Space Size | Dedicated Dump Device Size |
---|---|---|
Workstation with approximately 4 Gbytes of physical memory | 1 Gbyte | 1 Gbyte |
Mid-range server with approximately 8 Gbytes of physical memory | 2 Gbytes | 2 Gbytes |
High-end server with approximately 16 to 128 Gbytes of physical memory | 4 Gbytes | 4 Gbytes |
In addition to the general guidelines, consider allocating swap or disk space for the following:
A dedicated dump device.
Determine whether large applications (like compilers) will be using the /tmp directory. Then allocate additional swap space to be used by TMPFS. For information about TMPFS, see "Swap Space and the TMPFS File System".
Monitoring Swap Resources
The /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.
# swap -l swapfile dev swaplo blocks free /dev/dsk/c0t0d0s1 136,1 16 1638608 1600528 |
Use the swap -s command to monitor swap resources.
# swap -s total: 57416k bytes allocated + 10480k reserved = 67896k used, 833128k available |
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
Keyword | Description |
---|---|
bytes allocated | The total amount of swap space in 1024-byte blocks that is currently allocated as backing store (disk-backed swap space). |
reserved | The total amount of swap space in 1024-byte blocks that is not currently allocated, but claimed by memory for possible future use. |
used | The total amount of swap space in 1024-byte blocks that is either allocated or reserved. |
available | The total amount of swap space in 1024-byte blocks that is currently available for future reservation and allocation. |
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 add another disk. For information on how to repartition a disk, see Chapter 31, Managing Disks (Overview).
Creating a Swap File
The following general steps are involved in creating a swap file:
Creating a swap file with the mkfile command
Activating the swap file with 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
The 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
Option | Description |
---|---|
-n | Creates an empty file. The size is noted, but the disk blocks are not allocated until data is written to them. |
-v | Reports the names and sizes of created files. |
Caution - Use the -n option only when you create an NFS swap file.
How to Create a Swap File and Make It Available
Become superuser.
You can create a swap file without root permissions. However, to avoid accidental overwriting, root should be the owner of the swap file.
Create a directory for the swap file, if needed.
# mkfile nnn[k|b|m] filename
The swap file of the size nnn (in Kbytes, bytes, or Mbytes) and filename you specify is created.
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 can't unmount a file system while some process or program is swapping to the swap file.
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, as follows:
/path/filename - - swap - no -
Verify that the swap file is added.
$ /usr/sbin/swap -l