Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Swap size for hibernation question
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
leonchik1976
Tux's lil' helper
Tux's lil' helper


Joined: 24 Jan 2010
Posts: 138

PostPosted: Wed Sep 13, 2017 3:17 am    Post subject: Swap size for hibernation question Reply with quote

I have 64gb RAM, does it mean, that i need 64gb swap for successful hibernation?
Back to top
View user's profile Send private message
LIsLinuxIsSogood
Guru
Guru


Joined: 13 Feb 2016
Posts: 471

PostPosted: Wed Sep 13, 2017 3:50 am    Post subject: Reply with quote

That is not how swap space or memory work. The way that swap is used (if at all) is when memory is getting close to full to create some free memory space by moving over some of that. Since you have plenty of memory it really unnecessary to have all that swap space. Probably just follow what the suggestion of the wiki says, but I think it is something like 1 or 2GB should be plenty.

As far as hibernating and the use of swap for that, I was not aware of the problem with needing to have a minimum amount of swap space for that. But it does make sense. The thing you should consider is that when your system is running right before hibernating it probably is using a fraction of the total overall memory. And it should be possible to send that to any part of the disk in order to hibernate to disk. Are you trying to go with hibernate to disk?
Back to top
View user's profile Send private message
The Doctor
Moderator
Moderator


Joined: 27 Jul 2010
Posts: 2340

PostPosted: Wed Sep 13, 2017 3:51 am    Post subject: Reply with quote

Yes. The swap is used to store the state of the ram during hibernation.

A swap file may be more to your taste under the circumstance.
_________________
First things first, but not necessarily in that order.
Back to top
View user's profile Send private message
HungGarTiger
Tux's lil' helper
Tux's lil' helper


Joined: 04 Feb 2014
Posts: 130
Location: /nz/auckland

PostPosted: Wed Sep 13, 2017 3:53 am    Post subject: Reply with quote

In theory yes, as hibernation is storing the contents of your RAM in your swap space for later reuse. Though in practise I doubt you would be using 64GBs of RAM unless you go to hibernate in the middle of playing WoW. In order for a successful hibernation I would assume that it is needed or you might run into errors from time to time.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 6375
Location: almost Mile High in the USA

PostPosted: Wed Sep 13, 2017 5:18 am    Post subject: Reply with quote

How much swap space is needed for hibernation depends on your situation - First off, you need to add how much swap you would normally be using. Ideally with 64GB you won't swap so that should be 0.

There is also the transcendent memory swap. Coupled with this is zswap, more later.

Then how much RAM are you using. All cache will be saved though buffers will be flushed. There was a good reason why cache is saved but I don't remember what for, probably so that the machine upon resume will be on the ground running instead of a whole storm of cache misses.

This "real" hibernation image usage is actually compressed. I believe it uses a "normal" compress routine so you get fairly good compression ratio unless you were working on compressed data or had lots of transcendent memory zswap areas.

I would say for 64GB RAM and if you NEVER use swap for real swap (I've seen 512GB machines swap before, so don't say I didn't warn you...) then for hibernation you probably can get away with 32GB. 48GB would be "safe", but if you have the disk space, 64GB would be optimal in case you swap and can still hibernate.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1338
Location: United Kingdom

PostPosted: Wed Sep 13, 2017 5:39 pm    Post subject: Reply with quote

Back in 2010 I performed a small experiment to see how much swap space would be required for hibernation when using TuxOnIce. I found that, with in-kernel LZO compression enabled, the amount of swap space used for hibernation was 23 per cent of my then laptop's 4GB RAM.

The TuxOnIce developer stated in 2009 that:

Nigel Cunningham wrote:

> * How the installer of a Linux distribution should decide on the size of
> the hibernation file/partition? Worst case seems to be the installed
> memory size + swap partition but given that LZO compresses the image
> well enough is it possible to assume a size for the image file based on
> some proportions or something else?

LZO compression almost always achieves greater than 50% compression, so
you should be able to fit all images in swapspace equal to half the
amount of memory you have. Of course you might want to add a margin for
normal swapping and variations in the compression that's achieved.

I have not used TuxOnIce for several years, but I wonder if enabling compression in one's kernel configuration (without using TuxOnIce) would result in a significant reduction in the memory image when hibernating, and thus a significant reduction in the required size of the swap partition. I would imagine it would if using LZO compression. It would be worth trying various swap partition sizes to see, if you can be bothered.
_________________
Clevo W230SS: amd64, OpenRC, nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64, OpenRC, xf86-video-ati, dual booting with Win 7 Pro 64-bit.
KDE on both laptops.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 6375
Location: almost Mile High in the USA

PostPosted: Wed Sep 13, 2017 5:58 pm    Post subject: Reply with quote

Probably worst case is you have some mp3s or movies in your tmpfs ... Then likely you'll need a full swap=physical memory size.

However if you don't keep these things in buffer, cache, or tmpfs/ramfs, then you'll likely be fine with smaller hibernation areas.

I'm glad they thought of compressing the hibernation image, I was quite upset the first time I tried using hibernation, took forever, the first thing I thought was that they should compress as it would both speed up hibernation time as well as reduce SSD wear.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum