Библиотека сайта rus-linux.net
7.3. Using a swap space
|
/etc/fstab
file.
/dev/hda8 none swap sw 0 0 /swapfile none swap sw 0 0 |
|
Mem:
) shows the
physical memory. The total column does not show the physical
memory used by the kernel, which is usually about a megabyte.
The used column shows the amount of memory used (the second
line does not count buffers). The free column shows completely
unused memory. The shared column shows the amount of memory
shared by several processes; the more, the merrier. The buffers
column shows the current size of the disk buffer cache.That last line (Swap:
) shows similar
information for the swap spaces. If this line is all zeroes,
your swap space is not activated.
The same information is available via
top, or using the proc filesystem in file
/proc/meminfo
. It is currently difficult
to get information on the use of a specific swap space.
A swap space can be removed from use with swapoff. It is usually not necessary to do it, except for temporary swap spaces. Any pages in use in the swap space are swapped in first; if there is not sufficient physical memory to hold them, they will then be swapped out (to some other swap space). If there is not enough virtual memory to hold all of the pages Linux will start to thrash; after a long while it should recover, but meanwhile the system is unusable. You should check (e.g., with free) that there is enough free memory before removing a swap space from use.
All the swap spaces that are used automatically
with swapon -a can be removed from use
with swapoff -a; it looks at the file
/etc/fstab
to find what to remove.
Any manually used swap spaces will remain in use.
Sometimes a lot of swap space can be in use even though there is a lot of free physical memory. This can happen for instance if at one point there is need to swap, but later a big process that occupied much of the physical memory terminates and frees the memory. The swapped-out data is not automatically swapped in until it is needed, so the physical memory may remain free for a long time. There is no need to worry about this, but it can be comforting to know what is happening.