next up previous contents index
Next: The root partitions Up: Before You Begin Previous: Partitioning the Hard Drive   Contents   Index

The Swap Partition

Linux systems typically use a partition as swap space. This is where unused items taking up space in memory are placed until they are needed again so that the memory they are using can be used for something else. Other operating systems use a file on the file system for this purpose, and while Linux can be set up to do the same thing it is typically set up to use a swap partition because it is faster and isolated from the rest of the file systems.

You can't have too much swap space. Although excessive swap space may amount to wasted resources, it will not cause the system to exhibit thrashing or otherwise cause operational problems. It simply will not get used unless memory usage escalates.

Note: Thrashing - When the operating system spends most of its time paging real memory in and out of the swap space it is said to be ``thrashing'' and no useful work gets done. This can happen for a variety of reasons. On another operating system, larger than ``optimum'' swap space would quickly drive the system into thrashing. Deciding the amount of RAM that will be swapped out based on the size of swap space causes ``all'' pages to be swapped out immediately after they are used and the machine spends all its time moving pages in and out of memory and never gets anything done. (Well, at least it seems like it) The more reasoned approach is to base swapping activity on the age of the unused page and the amount of free memory. As the amount of free memory decreases, pages get swapped at an earlier age. This can still be made to thrash if placed under enough load. With many processes allocating and using many buffers, memory can fill up faster than it can be swapped out. The end result is either machine lockup because of exhausted memory or it begins thrashing when the swap age gets to zero.

More real memory does not necessarily mean more swap space. The need for swap is much more dictated by the demands of the processes that consume memory. Thus a swap ratio of 3 to 1 which works fine compiling kernels, as in the 24 MB swap to 8 MB RAM in the above example, fails when given a larger task. But the same ratio on a 16 MB machine gives 48 MB of swap space. This will be adequate for a large task but may still fail under a heavier load.

Although large disk drives are dirt cheap, there is not always any dirt available, and you are forced to compromise. Often after parceling out the disk, the left over partition space is not adequate to the swap needs. You are better off to take the space from the root partition and live in cramped disk space than to fall short of swap space. A workstation with 16 MB of memory will be able to do most any relatively complex work, including compilation of a math intensive package, without running out of virtual memory, with only a 48 MB swap partition. More memory in this environment means less swap. Less memory means more swap.


next up previous contents index
Next: The root partitions Up: Before You Begin Previous: Partitioning the Hard Drive   Contents   Index
Dale Scheetz