Swap and Virtual Memory
If you run out of real memory, Linux has a virtual memory system that automatically moves memory pages (chunks) to and from a hard disk. This is called swapping, because the pages of idle programs are swapped to the disk in exchange for active pages residing on the disk. The disk area used to store memory pages is called swap space.
The free
command's output includes the current swap usage in kilobytes as follows:
total used free ... ... ... ... Swap: 514072 189804 324268
Using a Disk Partition as Swap Space
To use an entire disk partition as swap, follow these steps:
Make certain that the partition is empty.
Run
mkswap dev
, wheredev
is the partition's device. This command puts a swap signature on the partition.Execute
swapon ...
Get How Linux Works now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.