Swap Size

Hi, a quick question regarding swap size.

If I upgrade my system memory, as I have done recently from 2GB to 4GB, I should increase my swap partition size, correct?

What is the best way of achieving this?

Unless you are using virtualisation or memory intensive programs (such as KDE eye-candy), you don’t need to do anything. Assuming you currently have 3Gb swap, I doubt you have been using much, if any, of it. If you still have the My computer icon click on this (or enter sysinfo:/ in a browser) to find out how much swap you are using.

On 2011-12-22 10:26, pv1962osl wrote:
>
> Hi, a quick question regarding swap size.
>
> If I upgrade my system memory, as I have done recently from 2GB to 4GB,
> I should increase my swap partition size, correct?

Not required unless you hibernate your machine.

> What is the best way of achieving this?

It depends on your partition layout. Do you have unpartitioned space?


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Well, you got some answers, but I sincerely would ask, how can anybody know if you do not even tell how large it is at the moment? These other guys must be claivoyant.

Thanks for the answers. Yes I should have told you what is currently is, it’s 2054 MB, that’s what it defaulted to on installation of 12.1, when I had 2GB memory. I don’t hibernate so that’s one reason not to worry about it, and generally in normal use I see usage of less than 5%. But I have just started playing with virtualisation and am seeing a lot higher usage of it when running virtual OS.

Unfortunately I don’t have any un-partitioned space, I used the lot on /, /home and /swap.

So at this stage I might just leave it as it is and wait till 12.2 when I re-install and take care of it then.

On 2011-12-22 12:06, pv1962osl wrote:
> So at this stage I might just leave it as it is and wait till 12.2 when
> I re-install and take care of it then.

As you don’t hibernate, if you find later that you need swap, you can also
use a big file as swap.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

  1. The installer might be able to offer you a default Swap at install depending on the size of your memory, thus that delfault might not be as fixed as you seem to think. (That is of course apart from all the changes you could have done to that default during install or afterwards).

  2. Swap space does not have to be contiguous, thus you could use a second Swap partition on the same or another disk additional to what you have (but I agree you do probably not need it).

  3. Swap space is not restricted to disk partitions. You can have file swap. Thus when you need more and can not (easily) create some partition, you can use a file on one of your existing partitions where there is e.g. 1 GB of unused space left.

With your amount of RAM you might think of adjusting (reducing) swappiness as the default is a bit generous (probably for servers). I have 8Gb RAM and 4Gb swap (I do use VMs quite a lot) but after adjusting swappiness (can’t remember the value, it was only a relatively small adjustment) I haven’t seen swap used at all for months, whatever I do.

On 2011-12-22 12:26, gminnerup wrote:
>
> With your amount of RAM you might think of adjusting (reducing)
> swappiness as the default is a bit generous (probably for servers). I
> have 8Gb RAM and 4Gb swap (I do use VMs quite a lot) but after adjusting
> swappiness (can’t remember the value, it was only a relatively small
> adjustment) I haven’t seen swap used at all for months, whatever I do.

That is not necesarily good: it can be bad and make your system actually
run slower.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

On 2011-12-22 12:26, hcvv wrote:

> 2) Swap space does not have to be contiguous, thus you could use a
> second Swap partition on the same or another disk additional to what you
> have (but I agree you do probably not need it).
>
> 3) Swap space is not restricted to disk partitions. You can have file
> swap. Thus when you need more and can not (easily) create some
> partition, you can use a file on one of your existing partitions where
> there is e.g. 1 GB of unused space left.

Both true, with the exception, I think, of hibernation.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

On Thu, 22 Dec 2011 09:48:07 +0000, Carlos E. R. wrote:

> On 2011-12-22 10:26, pv1962osl wrote:
>>
>> Hi, a quick question regarding swap size.
>>
>> If I upgrade my system memory, as I have done recently from 2GB to 4GB,
>> I should increase my swap partition size, correct?
>
> Not required unless you hibernate your machine.

And even then, it may not be necessary because the RAM image is
compressed when written out (generally, IIRC).

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2011-12-23 02:27, Jim Henderson wrote:
>> Not required unless you hibernate your machine.
> And even then, it may not be necessary because the RAM image is
> compressed when written out (generally, IIRC).

Yes, that is correct, but will depend on how compressible is the ram.
Perhaps you are working with huge random number tables in memory. Better
cover the worst case :wink:


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

I’m aware of that, all part of the fun of experimentation. So far, the sky hasn’t fallen in and while I haven’t noticed any turbo effects, it’s not any slower either.

Good point. As the hibernation space is configured separate in the kernel parameters at boot (in /boot/grub/menu.lst) ther can only one hibernation space be configured I guess.

I guess that the concept is that Hibernation space is NOT the same as Swap space, but that you can use one of your Swap partitions for it (if big enough)

On 2011-12-23 10:56, gminnerup wrote:
> I’m aware of that, all part of the fun of experimentation. So far, the
> sky hasn’t fallen in and while I haven’t noticed any turbo effects, it’s
> not any slower either.

Just consider: having things in swap means more ram available for things
that are actually used, like disk caches.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Probably rather academic for a desktop machine with 8Gb RAM (or even the OP’s 4GB). As I understand it, the positive effect (i.e. no slight delays while things are retrieved from swap) must outweigh any performance effects from reduced caches - the former I notice, the latter I don’t.

On 2011-12-24 10:46, gminnerup wrote:
>
> robin_listas;2421717 Wrote:

> Probably rather academic for a desktop machine with 8Gb RAM (or even

I have seen my 8 GiB ram machine using several GiB of swap.

> the OP’s 4GB). As I understand it, the positive effect (i.e. no slight
> delays while things are retrieved from swap) must outweigh any
> performance effects from reduced caches - the former I notice, the
> latter I don’t.

It is not that real. You would have to time with a chronometer the exact
same load in both cases. My bet is that the machine is faster with defaults
in most tests.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

But that’s my point: I don’t use a chronometer for performance evaluation. I don’t care about nanoseconds. But I do care about a few seconds to revive Firefox or whatever from swap.
Anyway, this is probably not a life-or-death issue :wink:
¡Feliz Navidad y feliz año nuevo!

On 2011-12-24 14:46, gminnerup wrote:
>
> But that’s my point: I don’t use a chronometer for performance
> evaluation. I don’t care about nanoseconds. But I do care about a few
> seconds to revive Firefox or whatever from swap.

But that’s the point, it doesn’t take longer.
And, if it does, other ops run faster, like saving or opening a file in
LibreOffice.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Oh yes it does because reading from disk takes longer than reading from RAM. We’re talking a few seconds here.

Perhaps, but nobody notices in real life. We’re talking nanoseconds here.