7

I am running Ubuntu 13.10, and I manage to suspend to RAM without any incidents. Suspending to disk (hibernate), however, does not work the second time I do it (after a reboot).

I tried to hibernate with pm-hibernate and also with uswusp.

The first time after a re-boot it goes fine, but if I try to hibernate again, it will hung with the message s2disk snapshooting system and I'll have to re-boot.

My swap partition is bigger than my RAM.

My /etc/default/grub:

GRUB_DEFAULT="5"
GRUB_HIDDEN_TIMEOUT_QUIET="true"
GRUB_TIMEOUT="10"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="resume=UUID=6a6e6406-4022-4620-bb36-fbf29f5c1cdf"
GRUB_SAVEDEFAULT="false"

I run update-grub after changing the CMDLINE_LINUX parameter.

My /etc/initramfs-tools/conf.d/resume:

RESUME=UUID=6a6e6406-4022-4620-bb36-fbf29f5c1cdf

Updated it after changing it with:

sudo update-initramfs -u

I tried 're-setting' my swap with:

sudo swapoff -a && sudo swapon -U 6a6e6406-4022-4620-bb36-fbf29f5c1cdf

but it didn't change anything.

Output of free -m:

               total       used       free     shared    buffers     cached 
 Mem:          1865         644       1220          0        111        328
 -/+ buffers/cache:         205       1659 
 Swap:         2044           0       2044

Output of name -a:

Linux QuoraF 3.11.0-13-generic #20-Ubuntu SMP Wed Oct 23 07:38:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Is there any way to maybe re-set what's wrong after the first hibernation? I imagine that the system creates something somewhere, and this something blocks subsequent hibernations.

David Foerster
  • 36,264
  • 56
  • 94
  • 147

3 Answers3

4

Found a solution. Running:

sync && sudo sysctl -w vm.drop_caches=3 && sudo sysctl -w vm.drop_caches=2

would clean the cache, and the system will be able to hibernate a second time after a re-boot.

I don't now what or why something was accumulating in memory. It should be a stack system, where new entries drag out entries not needed anymore.

Wilf's tips are still valid for a system using the swap space when running. I am using it only for hibernating That means, I had 2 GB, but were only using 1 GB. Had I a need of 3 GB for example, I wouldn't be able to hibernate my 2GB RAM computer using a 2GB swap partition.

  • Did you came up with the solution on your own or do you have a source? It looks to me as if you stumbled upon something that should be reported and fixed via bugreport, but I may be wrong on that. – LiveWireBT Feb 13 '14 at 07:22
  • @LiveWireBT: I didn't find anyone discussing a similar problem. Either people can hibernate, or they cannot, but being able to hibernate only once seems as pretty uncommon. Anyway, I imagined that something was accumulating. Since some people report having problems with the cache/buffer not being released, I tried their solution. – Quora Feans Feb 13 '14 at 13:12
  • Apparently you only need sysctl -w vm.drop_caches=3 - see here. Using it with sync command works as well. Anyway, you should be able to mark this as the answer if you want :D – Wilf Mar 06 '14 at 23:42
  • Could you expand on what this commands are actually doing? – M. Toya Oct 20 '17 at 11:37
1

I found a workaround for my machine, Asrock Z97 Fatal1ty, because HIBERNATE_MODE="platform" didn't work but "shutdown" does. Testing in the terminal by typing the following as root

echo shutdown > /sys/power/disk

and then

echo disk > /sys/power/state

performed hibernation and worked as many times as I tried. I tried several guides in attempt to change the default mode from "platform" to "shutdown" and none worked so I added the following line below to

/etc/rc.local

echo shutdown > /sys/power/disk 

and then save the file.

edit: I originally had typed "echo shutdown > /sys/mode/disk" and "echo disk > /sys/mode/state" in my original answer and realized my mistake. I also formatted the code the best i could. sorry for the unusual amounts of edits.

you can enable the hibernate menu option by creating the file:

/var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

and adding this to this empty file:

[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate
ResultActive=yes

and then logout and back in again and hibernate will be in the logout menu options and it worked every time. I know someone can improve this answer but I figured i'd share what worked for me anyways. Ideally one would find the correct file to edit the default mode for hibernation for pm-utils but like I said I tried and nothing worked, but this did. The only caveat I have encountered was that you now have to press the power button to resume from hibernate because the keyboard would not wake the computer like it did with "platform". Hope this helps someone.

Mark C
  • 161
0

Since it very likely that you don't have enough swap for hibernation, you may want to increase your swap space size.

There is varying opinion on what the size of the swap should be, but here is one from the Fedora 64bit docs (can't find the Ubuntu one... there was one, I did find it ages ago...):

For <2GB, it recommends  the swap should be '3 times the amount of RAM' in size.

So, it recommends 3 times the amount of RAM. This ends up as 5595Mib (5.5GiB), which should be plenty. I think this is to allow for the possible overflow of RAM plus the size of hibernation. On the actual process of increasing swap space, there are a few nice answers here.

If there is a Ubuntu version of the above info, I will gladly substitute in

Wilf
  • 30,194
  • 17
  • 108
  • 164