If you like continuing your work from where you left off the last time, such as when using multiple workspaces or regularly using the same applications to perform the same tasks arranged in a similar fashion, you would probably like your computer to remember how everything was arranged when you switched it off.
Of course, there is a special state called “hibernation” to allow for just that, but if you are an Ubuntu user you may have noticed that hibernation is no longer an option. Unfortunately, the standard hibernation that would save your computer’s state to disk before shutting down the system then reload it upon boot, was disabled in Ubuntu 12.04 and beyond for being buggy and unreliable.
If you are using the recent version of Ubuntu, the old dconf trick of turning on
org > gnome > gnome-session > auto-save-session will not work either.
Fortunately there is a way to re-enable hibernate in Ubuntu through editing some policykit configurations. So if you are confident in changing your system configurations, just follow the simple tutorial below.
Note: The below modifications have the potential to mess up your system. Please proceed with care and caution and make backups of your important data or even your entire system. Proceed at your own risk. The author is in no way responsible if anything breaks. If you don’t feel confident to troubleshoot a problem, it is best to close this browser window now, have a coffee, and forget about this tutorial at least for the time being.
Checking if hibernation works at all
Before proceeding with permanently changing your system, you should first try to see if you can hibernate it. For this you will need a swap partition that is at least as large as your physical RAM and that will auto-mount at system startup (if you installed Ubuntu with the default options you should probably have it). Save all your work (possibly even make backup if you prefer to be really safe), but leave some windows open. Now open a terminal either from your dash or with the keyboard shortcut “Ctrl + Alt + T” and type
Your system will shut down. Once it is completely powered off, turn it on and see if your last session was restored. If it worked, you can safely proceed; hibernation will work as expected. If your session did not restore, or if you encounter errors, that can be for a number of reasons, and unless you can iron it out, it is best not to proceed with the below modifications.
(MTE has already provided a short tutorial for enabling hibernation in Ubuntu 12.04. Things have changed a little since, so the previous tutorial might not work for the recent version of Ubuntu.)
If you are certain that hibernation will work on your system, you can put the hibernation menu back into where it used to be by creating the file
/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla as root with your favourite text editor. With nano you would type:
sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
and insert the following lines:
[Enable Hibernate in logind] Identity=unix-user:* Action=org.freedesktop.login1.hibernate ResultActive=yes
Ubuntu has switched from upower to logind since 14.04, so the above code should be sufficient. For earlier versions or if the above does not seem to work, you can try:
[Enable hibernate in upower] Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=yes
(Note: this will probably not work for versions below 13.10.)
If you are not sure, or just want to be on the safe side, you can include both versions.
[Enable Hibernate in upower] Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=yes [Enable Hibernate in logind] Identity=unix-user:* Action=org.freedesktop.login1.hibernate ResultActive=yes
Save the file and either reboot your system or restart the indicator session, with
The “Hibernate” options should now appear as before
Hibernation is a useful feature that would enable you to save your current session and continue working as if uninterrupted. Unfortunately removed by Ubuntu, the option can be easily re-enabled and used for enhanced productivity with the above simple method.
Our latest tutorials delivered straight to your inbox