Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

LXF154 Laptops Article - Hibernation Questions

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Magazine and coverdiscs
View previous topic :: View next topic  
Author Message
pc



Joined: Fri Apr 08, 2005 6:12 pm
Posts: 24

PostPosted: Sun Jan 29, 2012 8:59 am    Post subject: LXF154 Laptops Article - Hibernation Questions Reply with quote

I have a question about some information in this article.

I have never yet been able to get hibernation to work correctly under linux. Internet searching and asking questions, including on the LXF help forum, have not helped. In fact I have never received an answer to any forum posted questions.

In the "Quick Tips" box at the bottom of P53 it talks about hibernation. It says you require your swap to be twice your ram for this work.

I don't understand this statement and have not been able to find this "officially" documented anywhere. When hibernation mode is entered the contents of ram have to be written to disk (non-volatile memory) so that the ram can be de-powered. This enables the contents of the ram be restored when the machine is next powered on.

Question 1.
My understanding is that swap is effectively an extension of ram, it is used when the RAM is not large enough to hold everything required. So during hibernation the complete swap file contents must also be preserved. I don't see how making the swap size twice that of the ram ensures that the swap won't contain contents that mean there is not enough free space for the ram contents to fit during hibernation. Can you explain please?

Question 2.
During searches on the issue I have also found reference to statements that hibernation will not work if:
a) You have encrypted swap
b) You have encrypted home partition and/or whole disk
Can you comment on these statements please?

Hibernation on a Windows 7 laptop now works very well, even with whole disk PGP encryption. I believe Windows writes the ram contents to a separate file to enable its contents to be retained, that is separate to the swap file.

Look forward to a reply to help/correct my understanding
Back to top
View user's profile Send private message
pc



Joined: Fri Apr 08, 2005 6:12 pm
Posts: 24

PostPosted: Sun Jan 29, 2012 5:26 pm    Post subject: Additional information Reply with quote

Just for completeness I have dug out the bug I reported on hibernation in Ubuntu.
This references some of the information I was able to find on the subject.

https://bugs.launchpad.net/ubuntu/+source/hibernate/+bug/799919

The previous unanswered post in the LXF forums was:
http://www.linuxformat.com/forums/viewtopic.php?t=14002&highlight=hibernate

Perhaps you could take this question as one for the magazine questions section?
Back to top
View user's profile Send private message
Ram
LXF regular


Joined: Thu Apr 07, 2005 10:44 pm
Posts: 1672
Location: Guisborough

PostPosted: Sun Jan 29, 2012 7:58 pm    Post subject: Reply with quote

SWAP is usually on a physical hard drive partition, unless specified to use RAM in which case it would then be a volatile RAM disk.
_________________

lubuntu LXDE 13.10 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....


Last edited by Ram on Sun Jan 29, 2012 8:05 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
MartyBartfast
LXF regular


Joined: Mon Aug 22, 2005 8:25 am
Posts: 814
Location: Hants, UK

PostPosted: Sun Jan 29, 2012 8:03 pm    Post subject: Reply with quote

I believe all linux's hibernate by dumping memory contents to the swap partition/file, so I guess making swap twice physical memory will account for the situation where you've already maxed out memory, and have started using some swap, but there should still be enough swap space left to take the contents of physical memory; however this is just speculation.

My Fedora 16 laptop will happily hibernate to a swap file on an encrypted root partition using pm-hibernate, I can't test what it would do on an encrypted swap partition as my swap partition is only half physical memory.
_________________
I have been touched by his noodly appendage.
Back to top
View user's profile Send private message
pc



Joined: Fri Apr 08, 2005 6:12 pm
Posts: 24

PostPosted: Tue Jan 31, 2012 8:50 pm    Post subject: Reply with quote

Thanks for the replies.

Interesting point about the swap not having to be physical disk. I remember a machine a few years ago with something like 8Gbytes of ram, running a 32 bit OS, that used the RAM it could not address directly as memory, as a ram disk configured as SWAP.

I find it intriguing that there does not seem to be a simple explanation somewhere that explains what needs to happen, why, and if there are any options that can be changed to alter behaviour.

Making SWAP twice the size of RAM, is fine if you are sure the machine will not use up more than half of its SWAP before hibernation. Linux being Linux I am suprized that hibernation does not have its only "hibernation direction/file" to write to, that if one wished could be flexible where it was mounted.
Back to top
View user's profile Send private message
Rhakios
Moderator


Joined: Thu Apr 07, 2005 12:18 am
Posts: 7633
Location: Midlands, UK

PostPosted: Tue Jan 31, 2012 9:06 pm    Post subject: Reply with quote

One way to avoid the problem of using lots of swap for hibernation (I generally find that Linux uses very little of the swap space I give it, and tweaking the swappiness leads to it using even less), would be to flush ram caches before hibernating, so that only programs/data in active memory are written to swap.
Of course, it might well do this, but as I only use sleep and haven't set up enough swap to permit hibernate, I'm not going to find out.
_________________
Bye, Rhakios
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8464
Location: Warrington, UK

PostPosted: Tue Jan 31, 2012 11:43 pm    Post subject: Reply with quote

pc wrote:
Making SWAP twice the size of RAM, is fine if you are sure the machine will not use up more than half of its SWAP before hibernation. Linux being Linux I am suprized that hibernation does not have its only "hibernation direction/file" to write to, that if one wished could be flexible where it was mounted.


Not everything in RAM, and more so with swap, needs to be saved. Disk caches for example. On top of that, the data is compressed before saving, so even a fairly full system can be hibernated. However, I have seen a system fail to hibernate for lack ofstorage space.

The TuxOnIce advanced hibernation can use a file as the hibernate target.
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
pc



Joined: Fri Apr 08, 2005 6:12 pm
Posts: 24

PostPosted: Sun Feb 05, 2012 12:06 pm    Post subject: Reply with quote

nelz wrote:

Not everything in RAM, and more so with swap, needs to be saved. Disk caches for example. On top of that, the data is compressed before saving, so even a fairly full system can be hibernated. However, I have seen a system fail to hibernate for lack ofstorage space.

Thanks for the reply. Point taken. I believe the disk caches show up as "buffers"? It got me thinking that also other data in the pc, that was not directly in RAM might need to be saved. Such as configuration of the chipset components.

I am still left with the question, why the magazine article said SWAP had to be twice the size of RAM for hibenation to work. Does this mean it will work "all the time"/"most of the time"?
If I make the SWAP only the same size of the RAM will it work "not at all"/"not very often". Would SWAP at 1.5 times RAM make it work more often than 1x, but not often as 2x?
I guess I cannot see the connection, as I don't see anything that sets a limit on the amount of data that has to saved.
Unless the data compression you are referring will "always"/"is likely to" offer a compression ratio of 2:1.

nelz wrote:

The TuxOnIce advanced hibernation can use a file as the hibernate target.

Any chance of more information in the magazine on this in terms of how to get a laptop using a standard distribution to hibenerate. Ubuntu gives me the option, it just doesn't appear to work. Fedora did not appear to give the option.
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Magazine and coverdiscs 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
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast