b5media.com

Advertise with us

Enjoying this blog? Check out the rest of the Technology Channel Subscribe to this Feed

New Linux User

Explanation: Do I Need a Swap Partition and If So, How Big?

by Jon on December 28th, 2005

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.

POSTED IN: General

7 opinions for Explanation: Do I Need a Swap Partition and If So, How Big?

  • AMIT SALUNKE
    Jan 21, 2006 at 1:33 am

    why it is necessary to create a
    swap partition size of 1.5 to 2 times the amount of physical RAM on system. If suppose i create the same size of Physical RAM of swap partition so its goint to do some problem with the system.
    kindly reply me.
    Thanking you

  • Jon
    Jan 23, 2006 at 5:43 am

    Hi Amit,

    The ‘1.5 to 2 times the amount of RAM’ rule is just a guideline. You can make a swap partition as big or as small as you’d like. Or, as in the case that I illustrated above, many systems with enough physical RAM will run without a swap partition at all.

    The swap partition will only be used if the physical RAM becomes full.Some systems swap a lot, some not very much.

  • AMIT
    Feb 14, 2006 at 10:41 am

    i have a internet broadband conection which is run on DHCP but for that we required to install the raspppoe protocol in the system. my ISP provide me the USERNAME and PASSWORD which i have to dial using dialer but its work on only in WINDOW bcause they provide the windows dialer they dont have linux dialer. so how to connect to internet using raspppoe protocol in
    RED HAT LINUX 9.
    kindly guide me to fix this problem.
    thanking you
    AMIT

  • Jon
    Feb 15, 2006 at 7:39 am

    Hi Amit,

    I’m sorry, I can’t really help you with that. Where I live in Canada we don’t have PPPoe so I have absolutely no experience with that. The easter side of Canada uses PPPoe, but not out here in the west.

    Anyone else have any ideas?

  • New Linux User » HOWTO: Check My System RAM With “Free”.
    Mar 15, 2006 at 9:03 pm

    […] Free will also give you a quick look at how much of your swap partition you’re using. Ironically, using free (or perhaps one of the other memory tools) is how I discovered once that I didn’t actually have a swap partition. […]

  • Consider These When You Dual boot Linux and Windows
    Oct 8, 2007 at 11:54 am

    […] Think about the number and sizes of the partitions you need. I need a swap partition, a root partition and a home partition. Well, at least that’s what I consider all the time. Others consider a partition that Windows and Linux could easily read and write to. (A FAT32 partition.) If you’d do a lot of reading and writing of files in both Linux and Windows, you might as well make that partition big. That, or, get an external drive. Hehe. ;) As for the size of the swap partition, my friends have recommended to me that I have it twice as big as my RAM. In any case, you could check out Jon ’s explanation on whether a swap partition is necessary or not. […]

  • Dave Mann
    Oct 24, 2007 at 1:30 pm

    Swap on a RAM Drive? I have an AMD64 box with 4GB of RAM. I’ve never used all of the 4GB even when running apps open on the 12 screens which I have set up. How would I make a RAM drive and then use it for swap? And make that setup “permanent” so it reestablishes each time I reboot (although I have not rebooted for something like 2 months, but you never know …)

Have an opinion? Leave a comment:




Check Spelling
Activate Spell Check while Typing
Site Meter
Close
E-mail It