11

I have seen the answer on How to disable hibernating?, but I have no such file. Possibly because that suggestion was written for Ubuntu, not Kubuntu (KDE, not Gnome).

I do not have a swap on my encrypted SSD, my system freezes (cannot even change Caps Lock) if I accidentally press the "Hibernate" button at "Energy management". My keyboard has a Hibernate button (Fn + F4) next to the volume control buttons and every time I press the wrong key, the system will freeze after.

So, what is the correct way to disable it? If there is no solution, a work-around is welcome too.

  • +1 This (and disabling suspend) is a very important question for anyone running OCZ Vertex2 drives... suspend/hibernate can instantly obliterate the drive with no hope of recovering a single byte. :( – Russ Sep 2 '11 at 3:04
6

Triggers for hibernation:

  • Press the Hibernate button in Kickoff -> Leave -> Hibernate
  • Press Hibernate on the Energy icon in the system tray
  • Send a dbus signal: qdbus org.kde.kded /modules/powerdevil suspend 4

When hibernation is triggered, this is the execution flow:

  1. /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux is called
  2. /usr/sbin/pm-hibernate is called with some arguments
  3. Logging starts to /var/log/pm-suspend.log
  4. Hooks are executed to prepare for hibernation. These hooks are located at /usr/lib/pm-utils/sleep.d/ and /etc/pm/sleep.d, and sorted by name (numbers first)
  5. performing hibernate is written to the log
  6. The shell function do_hibernate is called, instructing the system to hibernate
  7. When the system resumes, hooks are executed to restore from hibernation
  8. The system is running again

To disable hibernation, create /etc/pm/sleep.d/000no-hibernation with the next content:

#!/bin/sh
# prevents hibernation
. "$PM_FUNCTIONS"
[ "$1" = "hibernate" ] && inhibit || true

As 000no-hibernation is called before scripts like 00logging (outputs modules and memory info in the log), no applications or modules are interrupted or unloaded. This name was inspired by /usr/lib/pm-utils/sleep.d/000kernel-change. Beware of bug #665651 which makes non-zero return values of hooks fail to cancel suspend or hibernation.

This fixes the hibernation issue for me. Although the screen gets locked, I can live with this. It's much better compared to a crashing system.

| improve this answer | |
  • I've added || true to prevent a non-zero exitcode, which prevents suspending. Tested to work for suspend and blocking hibernate. – Lekensteyn Mar 4 '11 at 8:22
  • Great answer! Very thorough.. Thanks for posting what you found. Extending on it, this script (from the bug report you linked) cleanly stops both hibernate and suspend. Editing to do just one of them is also trivial. – Russ Sep 2 '11 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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