How can I disable Hibernate completely in Kubuntu?

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.