-   Linux - Newbie (
-   -   Size of the swap partition (

Nitram 12-04-2007 05:42 AM

Size of the swap partition
ok, so... what size should my swap partition be?
I was talking to a friend and asked him if it should be 1.5 times my ram
he just told me 1.5* was a windows thing
That's fine with me
but then I came across a page saying it should be at least equal to my ram.... so which one is it?

syg00 12-04-2007 05:51 AM

How long is a piece of string ??? ...
This comes up all the time - search here on LQ.

On desktop systems I use 2 Gig - disk is cheap, and on x86 that is the limit for a single extent (R/H has patched to increase this limit).

reddazz 12-04-2007 05:54 AM

You will get varied answers for this type of question because it can't be answered precisely. In the past it used to be 2x the ram on your machine, but these days this rule does not necessarily apply because some machines have a lot of ram and will barely touch the swap space. Look at how much ram you have on your system and what you use your system for and then come up with your own scheme for the swap.

b0uncer 12-04-2007 05:57 AM

It depends on what you need. This thing has already been asked and answered here, so you could have searched..

swap is used when RAM isn't enough, or for things that don't need to be in RAM necessarily (but do need to be "available"). Often when you're not doing anything massive, you notice that your swap space is almost (or completely) unused. On the other hand, if and when your RAM gets full, swap is used to extend it. Windows doesn't use a swap partition like Linux operating systems usually do, but a swap file (also possible on Linux). Need of swap depends on what you do - what you need to store there, and why.

If you have a lot of RAM (depends on the tasks done again, but for a normal desktop 1G or less works) you can leave swap off, and the machine still works. Problems won't occur as long as you have RAM free, that is, as long as swap isn't needed. If you then do get your ram filled up, and there's no swap space to extend to, things may get pretty slow..and I think your system then starts (or it should) killing processes in order to keep the system responding.

So..on older machines (with less RAM, say 32-256) the thumb rule was to have at least as much swap as there was RAM, or if there was little RAM, then 1,5*RAM. That was because small RAM is easily filled with intensive tasks, when ran, and therefore swap was the answer. Now if you had 1G or 2G RAM, there was no sense in taking 2-4G of RAM if you only do usual desktop things, surf the web and so on. On the other hand, if you're dealing with something heavy like video or (big) photo things, it's handy having swap available when needed - but in that case you would also get much RAM too, because it works way faster than swap does.

With modern harddisk sizes considered (around 100-500G), using a gigabyte of disk space for swap means nothing. It's like a droplet in the ocean. So even if you didn't use your swap most of the time, it's better to have it there (even if unused most of the time) than not have it there when you need it - so I'd say take as much swap as you have RAM, but if you've got 1G or more RAM, then don't bother reserving that much - 512M-1G should be sufficient even if you occationally did something that consumes memory. If you feel you don't do memory-consuming things, 512 is ok.

The "thumb rule" of 1x or 1,5xRAM used to be a handy way of telling a new user not to panic when asked how much swap s/he wants, because it was usually sufficient amount, and the user didn't have to think about what swap really is, how much s/he needs it, or what is little and what is much. Nowadays RAM sizes are both so big (compared to what they used to be) and vary a lot that it's difficult to throw in a thumb rule that works both for those who have "little" RAM and those who have "a lot of" it (compare 512M vs. 4G - pick any thumb rule, and it causes trouble at either end).

So, shortly: if you aren't short of harddisk space, pick 1G for swap, or if you worry about losing precious space, try 512M. Though I'm fairly sure it really isn't up to that 512 megabytes, so 1G would be the choice - you're probably never going to use it (at least fully), but on the other hand hopefully you're never going to run out of it.

Nitram 12-04-2007 05:59 AM

well I have 2 gigs of ram... and while I was running windows it was never used 100% barely even passed 60%
so I should be fine with about 500mb then right?

syg00 12-04-2007 06:05 AM

In Linux it'll all get used - do a search before asking why ...

All times are GMT -5. The time now is 12:21 AM.