By using swap space, programs can be started even when the memory is used to its maximum without having to shut down processes first. This also make a good buffer for when peaks of memory usage occur. Linux can add swap space in two ways, either as a swap file within the file system or as a separate partition.
Swapd is a dynamic swapping manager for Linux (Swapd works with Linux kernels version 2.4.23 or higher). Swapd provides the system with as much swap space (virtual memory) as is required at a particular time by dynamically creating swap files. This is more convenient than using fixed swap files and/or partitions because they ..
* Swap space are unused most of the time and are just taking up disk space
* Provide a limited amount of virtual memory.
On systems that have constant need for virtual memory it would still be wise to use a swap partition in parallel with dynamic swapping, since swap partitions provide much faster access than swap files.
Open terminal from Applications > Accessories > Terminal, and type following command to install
sudo apt-get install swapdAfter successful installation, start the swapd demon using command /etc/init.d/swapd start and finally take a look at /etc/swapd.conf and change what is necessary as per your requirement.
NOTE: The first thing you should know is that Linux supports only 8 swaps (either files or partitions) by default. If you intend to take full advantage of dynamic swapping, you should recompile your kernel (In include/linux/swap.h under Linux source directory change the value of MAX_SWAPFILES from 8 to 256. This defines how many swaps you will be able to have.) to support more swaps, or get one which already does.