Lesson 5 | Enabling swap space |
Objective | Enable swap space. |
Enabling swap Space
Swapping uses space on a hard disk as an extension of a computer's RAM. By utilizing swap, the operating system pretends that more RAM is
available than the machine actually contains.
Swapping: Swapping uses space on a hard disk as an extension a computer\'s RAM. By utilizing swap, the operating system pretends that more
RAM is available than the machine actually contains. The oldest files in RAM are "swapped out" to the swap partition until they are needed so
that other data can be "swapped in" to RAM.
Your swap should be about three times your RAM, or 256MB, whichever is smaller. You should add more swap as needed, but only if adding RAM
isn't an option. If your system has multiple drives, set up a swap
partition on each disk. The system views all swap space the same, but when it
reads and writes to the swap space, the multiple hard disks allow parallel accesses, increasing performance. However, Linux limits you to
eight swap
partitions, which means you can't put a swap partition on more than eight hard drives.
Execute the following steps to create a swap partition:
-
Set up the partition table and add a swap partition (or create a
swap file instead)
using either the
fdisk
or cfdisk
utility.
- Reboot the system.
- Create the swap partition using
mkswap
.
- Add an entry for the swap to
/etc/fstab
.
- Activate the swap partition or file using
swapon -a
.
- Check the swap partition's status using
swapon -s
.
The following Simulation steps you through the process of adding additional swap space.
add swap space
The next lesson explains how to add new drives.
Implementing Swap Space
Before moving on to the next lesson, click the Exercise link to check your understanding of how to implement swap space.
Implementing Swap Space