From MEPIS Documentation Wiki
Citation: *Linux swap space
Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.
Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.
Swap space will usually be a disk partition but can also be a file. Users may create a swap space during installation of Arch Linux or at any later time should it become necessary. Swap space is generally recommended for users with less than 1 GB of RAM, but becomes more a matter of personal preference on systems with gratuitous amounts of physical RAM (though it is required for suspend-to-disk support).
A swap partition can be created with most GNU/Linux partitioning tools (e.g. fdisk, cfdisk). Swap partitions are typically designated as type 82, however it is possible to use any partition type as swap. To set up a Linux swap area, the |mkswap| command is used. For example:
- mkswap /dev/sda5
To enable the device for paging:
- swapon /dev/sda5
To enable this swap partition on boot, add an entry to fstab:
(edit the file /etc/fstab)
/dev/sda5 none swap defaults 0 0
Generally speaking, mkswap is used to create swap, either on a partition or in a file.
The command swapon is used to activate or enable swap from a partition or a file.
The file /etc/fstab is the file system table, and it is used to identify mount points for disk partitions, swap space, and removable media. This file must be edited by the root user.
In the example above, replace /dev/sda5 by either the partition containing the swap space or the name of a swap file.