HOWTO: Disable Suspend and Hibernate – Ubuntu

09May10

For some people, such as myself, the suspend/hibernate features in Ubuntu cause trouble, in my case, a lockup, or just general misbehaviour of the system. And in the power menu, it’s all too easy to click one instead of another. So it makes sense to disable the features from the power menu.  The idea for this post, and the method for Ubuntu 10.04 comes from this thread over on UF.

Ubuntu 10.04

Open a Terminal from Applications>Accessories>Terminal. Type in the following, and hit enter. When prompted, provide your password

gksudo gedit  /usr/share/polkit-1/actions/org.freedesktop.upower.policy

There are two sections in this file, the first for suspend and the second for hibernate. Near the end of each section will be a line with:

<allow_active>yes</allow_active>

Change this entry from “yes” to “no” to disable hibernate/suspend.

<allow_active>no</allow_active>

Ubuntu 9.10

The only difference between the process for 10.04 and 9.10 is the location of the file. Use the following line instead to open the file.

gksudo gedit /usr/share/polkit-1/actions/org.freedesktop.devicekit.power.policy

That’s it! The hibernate and suspend options will no longer be shown in the power menu in Gnome, so no more accidental lockups for you!

Or me… 😉



19 Responses to “HOWTO: Disable Suspend and Hibernate – Ubuntu”

  1. Does this also disable the XF86Sleep hotkey function?

    • 2 evidex

      As far as I know, no, it just disables the link in the menu, rather than disabling the feature itself.

  2. 3 Maurício Luciano

    Great! This works fine! If you still want can add these lines using a terminal –>

    gconftool -s /apps/gnome-power-manager/buttons/hibernate -t string interactive
    gconftool -s /apps/gnome-power-manager/buttons/suspend -t string interactive

    this will disable the functions keys 😉

    • 4 evidex

      I’ll have to look into that and add it to the blog post 🙂 Thanks mate 🙂

    • 5 Wastl

      Thanks a lot Maurício! I wanted to set the XF86Sleep key to “Lock Screen” and defined it as such in System>Preferences>Keyboard Shortcuts. However, pressing the key always invoked suspend. Obviously, the setting in /apps/gnome-power-manager/buttons/suspend dominated “Lock Screen”. Thus, changing the value of /apps/gnome-power-manager/buttons/suspend from “suspend” to “nothing” in the gconf-editor resolves the problem.

      • Thx for this tips !

        Here is the full command to disable the suspend to happens while XF86Sleep is pressed :

        gconftool -s /apps/gnome-power-manager/buttons/suspend -t string nothing

  3. 7 Daniel

    thanks so much worked great, no one else has the ability to make things like this so easy, ur the best dude

  4. 9 Ron

    More “kudos”. This made my wife/kids PC a lots simpler.

    • 10 mitch

      THANK YOU…. I have been searching on the internet for a long time trying to resolve this problem. You fixed it in a matter of minutes. Thanks for your advice! No more accidental hibernations 🙂

  5. 11 fil

    thanx mate!real useful!lubuntu user here 🙂

  6. 12 Scott

    One problem with this approach is that the settings can be overwritten with a package upgrade. The preferred way to do it is documented in the pklocalauthority man page. In short, create a file in /etc/polkit-1/localauthority/50-local.d with a .pkla extension with the following contents:

    [Disable suspend]
    Identity=unix-user:*
    Action=org.freedesktop.upower.suspend
    ResultAny=no
    ResultActive=no
    ResultInctive=no

    [Disable hibernate]
    Identity=unix-user:*
    Action=org.freedesktop.upower.hibernate
    ResultAny=no
    ResultActive=no
    ResultInctive=no

    This works at least on Ubuntu 10.04.

  7. fully recommend this
    http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug

    it worked for me on an asus g73jw with the latest ubuntu natty

  8. 15 dj

    gksudo gedit /usr/share/polkit-1/actions/org.freedesktop.upower.policy….here hibernate is already activated but still i am unable to hibernate my machine. it does not appear in the menubar too.

    • 16 evidex

      How much RAM and swap does your machine have? You need to have at least as much swap as you do RAM to hibernate correctly.

  9. 17 dj

    gconftool -s /apps/gnome-power-manager/buttons/hibernate -t string interactive…..how to change dis comment to enabler hibernate…pls help

  10. 18 Dust

    Thank you 🙂