Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
+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

2 Answers 2

up vote 6 down vote accepted

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.

share|improve this answer
    
Well done -- thanks for documenting this. –  belacq Mar 4 '11 at 4:35
    
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

Did you check out this:

In gconf-editor disable the keys by unchecking :
/apps/gnome-power-manager/can_hibernate 
and
/apps/gnome-power-manager/can_suspend

Right click on these keys and set as mandatory.
share|improve this answer
2  
this is for GNOME... –  hhlp Feb 27 '11 at 16:35
    
Indeed, I need one for Kubuntu, which uses KDE as desktop. –  Lekensteyn Feb 27 '11 at 17:39
    
Woops, I am sorry. I misread your question. –  Olli Feb 27 '11 at 17:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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