How much paging space is needed?

You can use these commands to determine how much paging space is being used on your system:

free
Displays the amount of free and used memory in the system.
swapon -s
Displays swap usage summary by device. Equivalent to cat /proc/swaps.
Note: While the vmstat comand shows paging activity, it does not show clearly how much paging space is being used.

To determine how much paging space is needed, it is recommended that the paging space should be double the amount of physical memory. So if a system has 1 gigabyte of memory, the total paging space should be 2 gigabytes (although the 2 gigabytes can be separated onto more than one disk).

On Linux you should consider the following recommendations when configuring your paging space:

  • Use the disk or disks that are least utilized.
  • Do not allocate more than one paging page logical volume for each physical disk.
  • Avoid sharing the same disk with logical volumes.
  • Make all paging spaces the same size if possible.
  • Make all paging spaces have the same priority (man swapon on how to do that).

To make paging space available to your system, you must add and activate the paging space. The total amount of paging space is often determined by trial and error. One commonly used guideline is to double the RAM size and use that figure as a paging space target.

  • To list your current paging space, type: swapon -s
  • To add paging space, type: mkswap device
  • Add device to /etc/fstab
  • To activate paging space, type swapon -a or swapon device
Note: The device argument is usually a disk partition (like /dev/sdd4) but it can also be a file. Usually the partition type for paging is 0x82. Note that Solaris also uses this type. Make sure you do not overwrite a Solaris partition.

When is a system thrashing? When page space becomes depleted, the operating system attempts to release resources by first warning processes to release paging space and then by killing the processes. Use the oom_adj and oom_score tools in /proc/PID to set the thresholds at which this activity occurs.

For information and recommendations for changing values for your configuration, see the documentation of your Linux distribution.