LXF154 Laptops Article - Hibernation Questions

Comments, suggestions and questions about Linux Format magazine and the coverdiscs

Moderators: ChrisThornett, LXF moderators

LXF154 Laptops Article - Hibernation Questions

Postby pc » Sun Jan 29, 2012 8:59 am

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
pc
 
Posts: 24
Joined: Fri Apr 08, 2005 5:12 pm

Additional information

Postby pc » Sun Jan 29, 2012 5:26 pm

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/+sour ... bug/799919

The previous unanswered post in the LXF forums was:
http://www.linuxformat.com/forums/viewt ... =hibernate

Perhaps you could take this question as one for the magazine questions section?
pc
 
Posts: 24
Joined: Fri Apr 08, 2005 5:12 pm

Postby Ram » Sun Jan 29, 2012 7:58 pm

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.
Last edited by Ram on Sun Jan 29, 2012 8:05 pm, edited 1 time in total.

lubuntu LXDE 13.10 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....
User avatar
Ram
LXF regular
 
Posts: 1682
Joined: Thu Apr 07, 2005 9:44 pm
Location: Guisborough

Postby MartyBartfast » Sun Jan 29, 2012 8:03 pm

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.
User avatar
MartyBartfast
LXF regular
 
Posts: 817
Joined: Mon Aug 22, 2005 7:25 am
Location: Hants, UK

Postby pc » Tue Jan 31, 2012 8:50 pm

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.
pc
 
Posts: 24
Joined: Fri Apr 08, 2005 5:12 pm

Postby Rhakios » Tue Jan 31, 2012 9:06 pm

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
User avatar
Rhakios
Moderator
 
Posts: 7634
Joined: Wed Apr 06, 2005 11:18 pm
Location: Midlands, UK

Postby nelz » Tue Jan 31, 2012 11:43 pm

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)
User avatar
nelz
Site admin
 
Posts: 8550
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby pc » Sun Feb 05, 2012 12:06 pm

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.
pc
 
Posts: 24
Joined: Fri Apr 08, 2005 5:12 pm


Return to Magazine and coverdiscs

Who is online

Users browsing this forum: No registered users and 1 guest