Make a swap partition
Tuesday, March 18th, 2008Prerequisite: Basics of partitioning with fdisk and formatting with mkfs
So you learned a bit about fdisk and are familiar with mkfs a bit so far. But what about giving up some of your hard-drive for swap space? First let’s start off with what is swap space.
Physical memory is a limited resource on a computer. Only so many processes can fit in physical memory at any one time, though many more may actually be ready to run or execute. Swapping and paging algorithms allow processes or portions of processes to move between physical memory and a hard-drive (or in rare moments, usb drives). This frees up space in physical memory.
Swap space (called a paging file in Windows) is an area on disk that temporarily holds a process memory image. When physical memory demand is sufficiently low, process memory images are brought back into physical memory from the swap area on disk. Having sufficient swap space enables the system to keep some physical memory free at all times.
This type of memory management is often referred to as virtual memory and allows the total number of processes to exceed physical memory. Virtual memory enables the execution of a process within physical memory only as needed. However, swapping does have a downside. Compared to memory, disks are very slow. Memory speeds can be measured in nanoseconds, while disks are measured in milliseconds, so accessing the disk can be tens of thousands times slower than accessing physical memory. The more swapping that occurs, the slower your system will be. Sometimes excessive swapping or thrashing occurs where a page is swapped out and then very soon swapped in and then swapped out again and so on. In such situations the system is struggling to find free memory and keep applications running at the same time. In this case only adding more RAM will help.