If this answer does not work in Ubuntu 13.10, see here for an alternative answer
Hibernation was disabled on 12.04 for machines that are not certified with Ubuntu.
In order to enable hibernation you need to test whether it works correctly by running sudo pm-hibernate in a terminal. The system will try to hibernate. If you are able to start the system again then you are more or less safe to add an override.
[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
Or in 14.04 and later:
[Re-enable hibernate by default for login1]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate
ResultActive=yes
[Re-enable hibernate for multiple users by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate-multiple-sessions
ResultActive=yes
Save by pressing Ctrl-O then enter and then exit nano by pressing Ctrl-X.
Restart and hibernation is back!
Or run killall unity-panel-service to just reset the menu.
Some users will then need to run sudo update-grub to get the hibernate option to be available in the power menu. Some users may also have to at least log out then log in to get it to appear in the (upper right) power menu.
First you need to test your machine supports hibernation. Test it with the command:
sudo pm-hibernate # if not found install with "apt install pm-utils"
# or for newer Ubuntus above 17.04
sudo systemctl hibernate
Ubuntu 16.04 and above
For enabling in the interface you'll need to run sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla and fill with:
[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions
ResultActive=yes
Ubuntu 14.04 and 15.04
For enabling in the interface you'll need to run sudo nano /etc/polkit-1/localauthority.conf.d/52-enable-hibernation.conf for Ubuntu 14.04 and 15.04 and fill with:
[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
[Re-enable hibernate by default for login1]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions
ResultActive=yes
It has several stanzas as you might have multiple users (so that is doesn´t depend of multiple-users or upower as manager instead of login1)
First, I do recommend that you test if your laptop supports hibernation, because the reason why hibernation is disabled by default is because it sometimes has fatal results on some machines. Test your machine by
Ctrl+Alt+T and then sudo pm-hibernate
Your machine should hibernate. Wake your machine up after hibernation and observe if it misbehaves or if it acts normally. If you experience any abnormality after the hibernation, then I advise you don't continue with the following procedure. However, if it works just fine, continue to activate hibernation by
If the response with /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla does not work as in my case, don't forget to delete the file by:
In 12.04, I successfully enabled hibernate option in the indicator menu to hibernate. But Still I wasn't able to successfully resume from hibernate. I did follow these steps to fix this problem:
Enable Hibernate in 12.04
To enable Hibernate, I followed this answer from Dima.
After enabling hibernate, I could hibernate. But the problem is, I can't successfully resume from hibernate. Any time I start my PC from hibernate, it boots like a normal boot. So, I had to do these things to be able to resume from hibernate.
The fixes to be able to resume from hibernate
There is two way to fix this.
1. Editing the /etc/initramfs-tools/conf.d/resume file
The actually line will not match with this. Copy the value of UUID in between "..." double quote.
Open the resume file
gksudo gedit /etc/initramfs-tools/conf.d/resume
And in that file, add a line like this
RESUME=UUID=a14f3380-810e-49a7-b42e-72169e66c432
Don't forget to replace the actual UUID value you get from step 1. Save the file and exit gedit
Then in terminal, execute this command
sudo update-initramfs -u
You will now be able to resume from hibernation
2. Editing the /etc/default/grub file.
Open a terminal and execute the below command to open it
gksudo gedit /etc/default/grub
There will be a line like GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
. Edit the line to insert RESUME=UUID=<your-uuid-value-here> after the word splash.
For example in my case, the line looks like this after editing
[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes
If this answer does not work in Ubuntu 13.10, see here for an alternative answer
Hibernation was disabled on 12.04 for machines that are not certified with Ubuntu.
In order to enable hibernation you need to test whether it works correctly by running
sudo pm-hibernate
in a terminal. The system will try to hibernate. If you are able to start the system again then you are more or less safe to add an override.To do so, start editing:
Fill it with this:
Or in 14.04 and later:
Save by pressing Ctrl-O then enter and then exit nano by pressing Ctrl-X.
Restart and hibernation is back!
Or run
killall unity-panel-service
to just reset the menu.Some users will then need to run
sudo update-grub
to get the hibernate option to be available in the power menu. Some users may also have to at least log out then log in to get it to appear in the (upper right) power menu.First you need to test your machine supports hibernation. Test it with the command:
Ubuntu 16.04 and above
For enabling in the interface you'll need to run
sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
and fill with:Ubuntu 14.04 and 15.04
For enabling in the interface you'll need to run
sudo nano /etc/polkit-1/localauthority.conf.d/52-enable-hibernation.conf
for Ubuntu 14.04 and 15.04 and fill with:It has several stanzas as you might have multiple users (so that is doesn´t depend of multiple-users or upower as manager instead of login1)
p.s.: official documentation https://help.ubuntu.com/16.04/ubuntu-help/power-hibernate.html
Additionally, for those who want to disable the suspend button (for various reasons), proceed analogously...
Choose any file name, but this is one is verbose/convention:
Fill it with this:
Ctrl+O, Enter, Ctrl+X
No need to restart, it should be gone as soon as you go into the shutdown menu.
One more thing:
When you want to add the hibernation option to XFCE's panel, you have to right-click your name (topright) and select
properties
.After that a screen pops up:
Make sure, you check Hibernate like I did.
First, I do recommend that you test if your laptop supports hibernation, because the reason why hibernation is disabled by default is because it sometimes has fatal results on some machines. Test your machine by
Ctrl+Alt+T and then
sudo pm-hibernate
Your machine should hibernate. Wake your machine up after hibernation and observe if it misbehaves or if it acts normally. If you experience any abnormality after the hibernation, then I advise you don't continue with the following procedure. However, if it works just fine, continue to activate hibernation by
Edit the opened file and add this lines:
After this, restart your machine, and upon login, you should see a hibernation option on the top right settings corner.
Enabling hibernation with a script
I have translated above answers to
bash
scripts. This makes installation on multiple machines less tiresome.Script
enable-hibernate
:Script
disable-suspend
:Note: Do not forget to
chmod +x
both scripts to make them executable.If the response with
/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
does not work as in my case, don't forget to delete the file by:And try to use TuxOnIce.
First ensure you have enough of swap. It should be the same size or bigger as the amount of your RAM. Use command
rule Swap > Mem. If this is not the case, enlarge your swap size. Then install TuxOnIce by
Then you can try to do a hibernate test run by:
Do not forget to save your work before you do it.
If all went fine, your computer will switch off. After switching it on, you will get your desktop in the state you left in it before hibernation.
A simple command which does the exact same thing as the accepted answer except non-interactively:
In 12.04, I successfully enabled hibernate option in the indicator menu to hibernate. But Still I wasn't able to successfully resume from hibernate. I did follow these steps to fix this problem:
Enable Hibernate in 12.04
To enable Hibernate, I followed this answer from Dima.
After enabling hibernate, I could hibernate. But the problem is, I can't successfully resume from hibernate. Any time I start my PC from hibernate, it boots like a normal boot. So, I had to do these things to be able to resume from hibernate.
The fixes to be able to resume from hibernate
There is two way to fix this.
1. Editing the
/etc/initramfs-tools/conf.d/resume
fileFirst get the UUID of the swap partition.
This will output a line similar to this:
The actually line will not match with this. Copy the value of UUID in between
"..."
double quote.Open the resume file
And in that file, add a line like this
Don't forget to replace the actual UUID value you get from step 1. Save the file and exit gedit
Then in terminal, execute this command
You will now be able to resume from hibernation
2. Editing the
/etc/default/grub
file.Open a terminal and execute the below command to open it
gksudo gedit /etc/default/grub
There will be a line like
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
. Edit the line to insertRESUME=UUID=<your-uuid-value-here>
after the wordsplash
.For example in my case, the line looks like this after editing
Make sure, you used your UUID value you get from
sudo blkid | grep swap
command.Then do this command
This also enable you to successfully get resumed from hibernate.
Tested on two Ubuntu installation, both worked
I have Ubuntu Gnome 17.04 amd64 on my notebook. I did the following to enable hibernation:
$
sudo apt-get install hibernate
(source)This installed also
libx86-1
uswsusp
vbetool
Then I could successfully hibernate with
sudo systemctl hibernate
. There is nopm-hibernate
executable in my path.$
sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
Inserted: (source)
Installed https://extensions.gnome.org/extension/755/hibernate-status-button/