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

Posted in Technology
Wed, Dec 28 - 11:04 am EST | 9 years ago by
Comments: 8
Share This Post:
  • Facebook
  • StumbleUpon
  • Tumblr
  • Reddit
  • Twitter

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.

Related Posts

Share This Post:
  • Facebook
  • StumbleUpon
  • Tumblr
  • Reddit
  • Twitter
  • http://www.yahoo.com AMIT SALUNKE

    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

  • http://www.newlinuxuser.com Jon

    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

    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

  • http://www.newlinuxuser.com Jon

    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?

  • Pingback: New Linux User » HOWTO: Check My System RAM With “Free”.

  • Pingback: Consider These When You Dual boot Linux and Windows

  • Dave Mann

    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 …)

  • axelf

    I want to install Linux and not have use a `swap` partition. Is it possible to do so from first install or can it be altered after first boot-up? I ask this because XP doesn`t give a choice so I have learnt to reduce the pagefile to about 150Mb and then turn it off altogether that way I don`t lose HD space and as I`m runnung 2Gb of memory I don`t need virtual memory.

    Kind Regards, axelf