I am having a problem with hibernation in Ubuntu 12.10, it had worked fine in 12.04. When I try and hibernate it sometimes appears to hibernate throws up an error and returns me to the desktop. The error I get is this:

Now I understand what the error means, but it doesn't make sense. My swap file is 5GB and is seldom ever used as I have 4GB of RAM. I know it is recommended to have 1.5 times more swap than RAM etc, but space doesn't seem to be the problem, despite the error.

For example, I rarely use more than about 25%-30% of my RAM, yet still have the problem above.

Moreover on a fresh boot and login, with no programs open and using only about 12% of RAM, I can get the above error - yet at other times I can hibernate whilst using 25% of my RAM.

Also if I keep trying to hibernate, it eventually does after throwing up the above error four or five times. A successful hibernation looks like this:

Is there some setting that I need to tweak or something I need to do before hibernating to avoid this problem?

I guess the question could be better interpreted as: Is there some way of safely flushing the buffers and the cache before hibernation? Other than attempting to hibernate several times until it is successful!

2 Answers
2

Prior to attempting to hibernate, I no longer have a problem and it hibernates first time, every time. This appears to empty the cache, therefore leaving plenty of memory (RAM) free to create the image.

I am no programmer, but it seems illogical that Ubuntu doesn't do this prior to hibernation anyway? It obviously does something similar as repeated hibernation attempts have the same result eventually, but clearly it doesn't do it before attempting to hibernate. Surely it is inefficient when hibernating to also write all the buffers and cache to disk too, as they will also have to be re-loaded on resume, even if they are no longer needed. Surely it would be more efficient if Ubuntu dumped the cache, or at least parts that haven't been used for some time, before hibernation?

The fact it doesn't do this is probably the reason why it is recommended to have double the size of the RAM for swap space; terribly inefficient especially in the days of SSDs where if you have 16GB of RAM, you'd lose 32GB (potentially half of your HD space) of space to a swap file that is only ever used to hibernate.

With the ever increasing sizes of RAM, I'd say that this is an area that needs looking into. HD space may be cheap, but that is no excuse to waste it due to inefficiencies.

I've discovered that my problem may have been related to something else entirely and not the fact that the buffers and cache were full.

A few days after my last post I couldn't boot without a disk check running, but the disk checks hung and never completed. I eventually managed to get the disk checks completed manually, and it discovered lots of errors, which were then fixed.

On a whim I tried hibernation again without the below command to empty the cache and it was was successful. I have been hibernating first time ever since without problems, even at times with 30-40% RAM in use, and without the need to clear the cache first, and it is always successful.

So it seems that the initial error was related to errors on the disk and not free memory at all and once these errors were fixed the problem went away. So if you receive the above error, you may wish to check all of your partitions for errors before trying anything else.