Ubuntu – How to disable Hibernate completely in Kubuntu

10.10encryptionhibernatekubuntu

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.

Best Answer

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.