What is swap for?
As we’ll see, there are basically four different purposes for swap :
To begin with, let’s say that computers have changed a lot since swap was first used :
Some programs really are memory-consuming :
Extra memory might come in handy :
Swap can optimize memory usage :
Hibernation needs swap
Do I Need a Swap Partition and If So, How Big?
A computer running GNU/Linux generally has a few different partitions on it (not including any Windows or other OS dual boot scenarios). There’s usually a small Master Boot Record (MBR) partition which houses your boot loader (usually GRUB or Lilo); a system partition which houses your actual OS (usually quite large), and there’s usually a swap partition.
I have another paritition which I use as my home directory, but that’s kind of a specialized, yet common, set up.
The swap partition is used to help your system run faster. When your system runs out of physical RAM during operations, it uses the swap partition as RAM and writes little bits of stuff that is currently in RAM, but not needed, to the swap partition. This allows you to run more programs at once. The alternative to having swap is…well…not having swap. In this scenario, when you’ve opened up enough applications that your physical memory fills up, there’s no place to write the overflow and your system will bog down quite miserably.
Most modern OSes have some sort of swap facility. In Windows this is referred to as the pagefile, and I’m not sure what it’s referred to as on a Mac.
So, the answer seems obvious, doesn’t it? Swap is good. You should have swap and worship it every day.
I can’t argue with that. Swap is good, but in many systems it’s not necessary. I discovered this completely by accident one day. I muffed up the partitioning when I installed Kubuntu and didn’t allocate a swap partition. The funny thing is that I didn’t notice for months and when I did notice it was by conversing with someone who asked me something about my swap, not due to any system performance issues.
Prior to this incident, I didn’t think it was possible to run a GNU/Linux box without swap, but it turns out that not only is it possible, some people do it on purpose.
In the home/desktop world, if you have a GB of RAM or more, your system may never swap anything out. The recommendations for allocating swap is anywhere from 1.5 to 2 times the amount of physical RAM on your system. On some systems, losing 2 to 3 GB of disk space might be a considerable loss and therefore not worth it.
In the server world, running without swap is propbably suicidal. Don’t do that.
If you’re curious, check out your swap usage now and again. With KDE you can use KDE System Guard and there are some gDesklets available for Gnome (and possibly a built in application as well, not sure) to view your swap usage.
Source : (Ubuntu Community – https://help.ubuntu.com), (Jon – newlinuxuser.com)