Disable suspend (suspend-to-ram) in Ubuntu


To totally unlock this section you need to Log-in


Login

You can disable suspend (suspend-to ram) as follows (only do it when really necessary, because it's generally a useful feature):

First make sure that you have installed the applications gksu and leafpad. Launch a terminal window and then type (or copy/paste):

 
sudo apt-get install gksu leafpad

Press Enter and submit your password. Please note that the password will remain invisible, not even asterisks will show, which is normal. Leave the terminal window open for the actual hack.

Copy/paste the following line into the terminal (use copy/paste to prevent typo's):

 
sudo touch /etc/polkit-1/localauthority/90-mandatory.d/disable-suspend.pkla

Press Enter.

Copy/paste the following line into the terminal (use copy/paste to prevent typo's):

 
gksudo leafpad /etc/polkit-1/localauthority/90-mandatory.d/disable-suspend.pkla

Press Enter.

Copy and paste the following blue text into that empty text file:

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

[Disable suspend (logind)] Identity=unix-user:* Action=org.freedesktop.login1.suspend ResultActive=no
[Disable suspend for all sessions (logind)] Identity=unix-user:* Action=org.freedesktop.login1.suspend-multiple-sessions ResultActive=no

Save the text file and close the text editor.

Reboot your computer (full reboot). Suspend should now no longer be one of the options in the shutdown menu.

On a laptop, it's advisable to check the power manager settings: you'll have to find alternatives for suspend, for actions like closing the laptop lid.

How to undo

Do you want suspend back? The above hack is easily reversible. Undoing it is very simple:

Launch a terminal window and then copy/paste the following line into the terminal:

sudo rm -v /etc/polkit-1/localauthority/90-mandatory.d/disable-suspend.pkla

Press Enter and submit your password. Please note that the password will remain invisible, not even asterisks will show, which is normal.

Reboot your computer. The suspend option should be back now.

Ubuntu 12.04

In Ubuntu 12.04 you will need to create only the /etc/polkit-1/localauthority/50-local.d/com.ubuntu.disable-suspend.pkla file with the below disabled suspend option to hide it in the main menu.

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