Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When a computer goes into hibernation mode, it saves the contents of the RAM into the swap space so that it can resume exactly where it left off when it powers back on.

So, what if you are currently using more memory than you have RAM. In this case, some data that would otherwise be in RAM is saved to swap.

An example. A computer has 1GB of RAM and 1GB of swap space. It is currently using all but 100MB of RAM and 500MB of swap. Thus, it is needing to remember about 1.4GB of memory to save its state. However, swap is only 1GB.

What will happen in this case?

~~ edit ~~

As answered below, the hibernate fails. So then a follow-up question:

When this fails, where is the error reported?

share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

That depends on the implementation of hibernation. Even if you restrict the question to Linux, the implementation has evolved over time.

First, consider that some of the RAM is used for disk caches. This doesn't need to be moved to the swap as it can be reloaded from the disk after the system resumes. On a system with a good cost/efficiency balance, it's typical for about half of RAM being allocated to caches. (See also Why use swap when there is more than enough RAM.) Under Linux, some early implementations would store all allocated memory into the swap, but the current implementation(s?) of hibernation skip disk caches.

Second, some systems compress memory as it's written to the swap, which can make the exact required amount of swap hard to predict. Some versions of Linux's hibernation support have supported compression; I don't know if current ones do.

What you can generally expect if there isn't enough swap space is that hibernation will fail: the system will try to store the (useful) contents of RAM into the swap, and as soon as it detects that there isn't enough space, the hibernation attempt is aborted (typically with an error message on the console and in the system logs). As far as I know, Linux has always behaved like this (not that there's really another sensible behavior).

share|improve this answer
1  
I tried this in a virtualbox machine and it did fail, although it didn't display any message to the user (I tried with ubuntu 10.4). What system log would have this error reported? –  David Oneill Nov 17 '10 at 17:20
3  
@David: There should definitely be something in /var/log/kern.log. I don't know whether the absence of a message on the console is a quirk of this particular kernel version or a deliberate Ubuntu configuration (I know they have deliberately suppressed some other console output). –  Gilles Nov 17 '10 at 19:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.